Watch Face para Garmin Fenix 3 HR

Recientemente me regalaron un Garmin 3 para que pueda registrar mis entrenamientos.

La idea es desarrollar Apps o Data Fields, y para empezar a ver como funciona, he creado un Watch Face para él.

Lo he desarrollado en Monkey-C. Usando el SDK de Garmin (Connect IQ) para Eclipse.  (Aunque luego he descubierto que hay una extensión para VS Code y he empezado a usarlo)

El reloj muestra la hora, fecha, Heart Rate y el porcentaje de batería restante.

El código en Github; Fenix 3 Watch Face Github

watch_face

Anuncios

Deja un comentario

Protegido: RTOS

Este contenido está protegido por contraseña. Para verlo introduce tu contraseña a continuación:

Deja un comentario

Entorno de compilación para el kernel

METODO 1

Debemos asignar al menos 2 nucleos de cpu y la mitad de la RAM del sistema (todo dentro de los parametros en verde)

sudo apt-get build-dep linux-image-$(uname -r)
sudo apt-get install libncurses5-dev bc

A continuación vamos a construir e instalar el kernel de linux

mkdir kernel
cd kernel
wget -c https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.13.2.tar.xz
tar xf linux-3.13.2.tar.xz
cd linux-3.13.2
cp /boot/config-$(uname -r) .config
make menuconfig # Do these activities in sequence (load -> exit -> save) for the .config file
# present in current directory using the ncurses buttons.
make -j5 # It will create arch//boot/bzImage
sudo make modules_install
sudo make install
sudo reboot

Si grub no reconoce el nuevo kernel, tendremos que ejecutar:
sudo update-grub

O en ocasiones que grub se corrompe el siguiente:
sudo grub-install /dev/sda

Modulo Hola Mundo

#include
#include

int init_module(void)
{
printk(KERN_INFO “init_module() called\n”);
return 0;
}

void cleanup_module(void)
{
printk(KERN_INFO “cleanup_module() called\n”);
}

kernel_code
Crear El siguiente Makefile

obj-m += hello.o
all:
make -C ~/kernel/linux-3.13.2/ M=$(PWD) modules
clean:
make -C ~/kernel/linux-3.13.2/ M=$(PWD) clean

Y a continuacion insertar y descargar el modulo:
sudo insmod hello.ko
lsmod | grep hello
dmesg | tail
sudo rmmod hello
lsmod | grep hello
dmesg | tail
testing

En dmesg podremos ver las salidas del módulo.

METODO 2
Instalar los siguientes paquetes:
sudo apt-get install fakeroot build-essential libncurses5 libncurses5-dev kernel-package

Obtener el codigo fuente (Se guarda en /usr/src):
sudo apt-get install linux-source

Descomprimirlo en nuestro home
tar xjvf /usr/src/linux-source-.tar.bz2
cd linux-source-

Usar la configuracion inicial como punto de partida:
cp -vi /boot/config-`uname -r` .config

Fijar la configuracion:
make menuconfig
Compilar el kernel:
fakeroot make-kpkg –initrd –append-to-version=-mykernv1 kernel-image kernel-headers
(Usa “make-kpkg clean” antes de construir el kernel para limpiar)

Instala el kernel:

sudo dpkg -i linux-image-.deb
sudo dpkg -i linux-headers-.deb

Crea el systema de archivos inicial en ram (initramfs) y actualiza grub
sudo update-initramfs -c -k
sudo grub-install /dev/sda
sudo update-grub
Reinicia el kernel:
sudo reboot now

Comprueba el kernel que se esta ejecutando.
uname -r

Deja un comentario

Protegido: Get Opt

Este contenido está protegido por contraseña. Para verlo introduce tu contraseña a continuación:

Deja un comentario

Crosscompiling for Raspberry

Once, I have my Raspberry Pi and QEMU environment working, I’m going to explain how to set up the crosscompiler:

First at all, We have to download crosstool-ng from its website: http://crosstool-ng.org/.

After that, I have unpacked the tarball,and run configure command (I had to resolve several depences before):

./configure --prefix=/opt/compiler/
make
make install

Now, I had to add the folder to the path:

echo $PATH | tr : \\n
PATH=$PATH:/opt/compiler

Now, execute ct-ng tool like that:

./ct-ng menuconfig

In “Path and misc options”, enable “Try features marked as Experimental”
I set up my folder like

/opt/compiler/tools/${CT_TARGET}

Theses was the rest of my options:

Then I executed the next command:

./ct-ng build

After 48 minutes my system is ready 🙂
I updated my path again:

PATH=$PATH:/opt/compiler/tools/arm-unknown-linux-gnueabi

then I made a simple program test, it was compiled :

arm-linux-gnueabi-gcc -o prueba prueba.c

🙂

Deja un comentario

Raspbian running in ubuntu with QEMU

You have to download the image from here:

http://141.30.228.4/pub/mirrors/raspbian/qemu/

I have use the next command based on the bat file:

sudo qemu-system-arm -M versatilepb -cpu arm1136 -m 256 -kernel raspbian/vmlinuz-2.6.32-qemu-armv6 -initrd raspbian/initrd.img-2.6.32-qemu-armv6 -hda raspbian/raspbian.img -net nic -net user -append “root=/dev/sda1”

Then, I had to reconfigure /etc/apt/sources.list like that:

deb http://archive.raspbian.org/raspbian wheezy main contrib non-free rpi
deb-src http://archive.raspbian.org/raspbian wheezy main contrib non-free rpi

After that we have to reconfigure our locales:

sudo apt-get install locales
sudo dpkg-reconfigure locales

and the keyboard:

sudo apt-get install keyboard-configuration
sudo dpkg-reconfigure keyboard-configuration

 

Deja un comentario

Playing with Qt and OpenCv

In this project I’m going to capture the image from a USB camera, using openCV, and showing all in a QT window.

Let’s started:

The first thing that we have to do, once we have created the project, is to edit the *.pro file, and add our OpenCv paths.

QT       += core gui
 TARGET = untitled
 TEMPLATE = app
 INCLUDEPATH += /home/opencv_source/trunk/opencv/include/opencv
 LIBS += -L/home/opencv_source/trunk/opencv/release/lib -lml -lcvaux -lhighgui -lcv -lcxcore
 SOURCES += capture.cpp\
 main.cpp\
 mainwindow.cpp

HEADERS  +=  capture.h\
 mainwindow.h

FORMS    += mainwindow.ui

I had a problem,  “undefined recerence to vtable” ,that I could fix placing on top capture.h and capture.cpp files.

Once we have ready our environment I’ll explain the content of the files:

– capture: Is the most important file, this class runs in other thread that the GUI, and all that it does is emitting a signal when has a new IplImage from the cam.

Create a new Thread in QT is so easy, all that we have to do is derivate from QThread and implement the virtual method void run()

class Captura : public QThread
 {
 Q_OBJECT              //We need this macro for use Signals mechanism
 public:
 void run();
 signals:
 void newImgAvailable(QImage*);
 };

void Capture::run()

{
 CvCapture * cap = cvCaptureFromCAM(0);
 if(cap == NULL)
 {
 cout << "There were troubles .. " << endl;
 }
 else
 {
 cout << "Ok" << endl;
 IplImage* imgDisplay;
 while(1){
 imgDisplay = cvQueryFrame(cap);
 QImage* image = IplImage2QImage(imgDisplay);
 emit newImgAvailable(image);
 QThread::msleep(10);
 }
 }
 }
<pre>

– In mainwindow we are going to create the instance of capture, start it, and connect with our own slots wich will set the image in a QLabel using setPixMap property.

The header:

class MainWindow : public QMainWindow
 {
 Q_OBJECT

public:
 explicit MainWindow(QWidget *parent = 0);
 ~MainWindow();

public slots:
 void getImg(QImage*);
 private:
 Ui::MainWindow *ui;
 };

and the cpp:

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),  ui(new Ui::MainWindow)
 {
 ui->setupUi(this);
 Capture* cap = new Capture();               //Create the Thread wich deals with opencv
 connect(cap, SIGNAL(newImgAvailable(QImage*)),this, SLOT(getImg(QImage*)));
 cap->start();  //starting the thread...
 }

void MainWindow::getImg(QImage* img)   //This code will update the image
 {
 ui->label->setPixmap(QPixmap::fromImage(*img));
 delete img;
 }

To avoid memory leaks we have to bear in mind that getImg has to delete the QImage.

Important: We mustn’t release the IplImage* in the loop, because this  is made internally and it would be a mistake

1 comentario