giovedì 21 maggio 2020

Social Distancing WristBand

In questo periodo in cui c'e' la corsa a creare dispositivi per il distanziamento sociale ho voluto vedere quanto era difficile realizzare un dispositivo di questo tipo


Come base hardware ho provato la M5StickC dotata di ESP32, Bluetooth, display a colori e batteria integrata. Il costo e' di circa 15 euro



L'idea generale e' il dispositivo espone un servizio bluetooth "Social Distance" (in realta' si dovrebbe dire social distancing..ma il display e' troppo piccolo :>) e scansiona i dispositivi bluetooth vicini per trovare altri nomi uguali. Usando il parametro RSSI si ha una stima approssimativa di quanto i braccialetti siano vicini

Il problema maggiore riscontrato durante lo sviluppo e' che la scansione Bluetooth richiede molta energia e scarica rapidamente la piccola batteria del braccialetto; anche accendendo lo schermo al minimo necessario e diradando il tempo di scansione non sono riuscito a superare i 40 minuti continuativi di utilizzo 

Il display diventa rossso quando i dispositivi sono vicini. Il tasto serve a vedere lo stato di carica della batteria. Il led rosso e' acceso quando il braccialetto e' in carica ma non ha raggiunto il 100% di carica e quando e' disconnesso dalla ricarica  

Questo e' il codice   

=================================================
//Bluetooth
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>
#include <BLEServer.h>
#include <BLE2902.h>

//Grafica
#include <M5StickC.h>

//Power management
#include "AXP192.h"

//BLE
int scanTime = 2; //In seconds
BLEScan* pBLEScan;

// Speaker
//const int servo_pin = 26;
//int freq = 50;
//int ledChannel = 0;
//int resolution = 10;
//extern const unsigned char m5stack_startup_music[];

int contatore = 1;



// Immagini  formato XBitmap
#define batteria_reverse_width 80
#define batteria_reverse_height 160

static unsigned char logo_bits[] = {
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00,
   0x00, 0x00, 0x7c, 0x00, 0xe0, 0x03, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
   0x7c, 0x00, 0xe0, 0x03, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
   0xe0, 0x03, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0xe0, 0x03,
   0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0xe0, 0x03, 0x00, 0xf8,
   0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0xe0, 0x03, 0x00, 0xf8, 0x00, 0x00,
   0x00, 0x00, 0x7c, 0x00, 0xe0, 0x03, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
   0x7c, 0x00, 0xe0, 0x03, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
   0xe0, 0x03, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0xe0, 0x03,
   0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0xe0, 0x03, 0x00, 0xf8,
   0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0xe0, 0x03, 0x00, 0xf8, 0x00, 0x00,
   0x00, 0x00, 0x7c, 0x00, 0xe0, 0x03, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
   0x7c, 0x00, 0xe0, 0x03, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
   0xe0, 0x03, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0xe0, 0x03,
   0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0xe0, 0x03, 0x00, 0xf8,
   0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0xe0, 0x03, 0x00, 0xf8, 0x00, 0x00,
   0x00, 0x00, 0x7c, 0x00, 0xe0, 0x03, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
   0x7c, 0x00, 0xe0, 0x03, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00,
   0xe0, 0x03, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0xe0, 0x03,
   0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0xe0, 0x07, 0x00, 0xf8,
   0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00,
   0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
   0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff,
   0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff,
   0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0xe0, 0x00, 0x70, 0x00, 0x00,
   0x00, 0x00, 0xc0, 0x00, 0x00, 0xe0, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00,
   0xe0, 0x01, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x03,
   0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x70,
   0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x07, 0x00, 0x70, 0x00, 0xe0,
   0x00, 0x00, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x70, 0x00, 0xe0, 0x00, 0x00,
   0x00, 0x00, 0xfe, 0x1f, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00,
   0xfe, 0x1f, 0x00, 0xe0, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0xff, 0x3f,
   0x00, 0xe0, 0x00, 0x70, 0x00, 0x00, 0x00, 0x80, 0xff, 0x7f, 0x00, 0xc0,
   0x03, 0x3c, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x00, 0xc0, 0xff, 0x3f,
   0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0x00, 0x80, 0xff, 0x1f, 0x00, 0x00,
   0x00, 0xe0, 0xff, 0xff, 0x01, 0x00, 0xfe, 0x07, 0x00, 0x00, 0x00, 0x00,
   0xe0, 0x01, 0x00, 0x00, 0xf0, 0x00, 0xff, 0xff, 0xff, 0x01, 0xe0, 0x01,
   0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x03, 0xe0, 0x01, 0x00, 0x00,
   0x00, 0x00, 0xff, 0xff, 0xff, 0x03, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0xf8, 0x7f, 0x00, 0x00, 0x00, 0x00,
   0xe0, 0x39, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3d,
   0x00, 0xc0, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3d, 0x00, 0xe0,
   0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x3d, 0x00, 0xe0, 0x01, 0x00,
   0x00, 0x00, 0x00, 0x00, 0xe0, 0x3d, 0x00, 0xf0, 0x00, 0x00, 0x00, 0xf8,
   0xff, 0x03, 0xe0, 0x39, 0x00, 0x70, 0x00, 0x00, 0x00, 0xfe, 0xff, 0x03,
   0xe0, 0x39, 0x00, 0x70, 0x00, 0x00, 0x00, 0xff, 0xff, 0x03, 0xe0, 0x39,
   0x00, 0x60, 0x00, 0x00, 0x00, 0xc7, 0xf1, 0x00, 0xe0, 0x39, 0x00, 0x60,
   0x00, 0x00, 0x80, 0xc3, 0xc1, 0x01, 0xe0, 0x79, 0x00, 0xe0, 0x00, 0x00,
   0x80, 0xc3, 0x81, 0x01, 0xe0, 0x79, 0x00, 0xc0, 0x01, 0x00, 0x80, 0xc3,
   0x81, 0x03, 0xe0, 0x79, 0x00, 0x80, 0x03, 0x00, 0x80, 0xc1, 0x01, 0x03,
   0xe0, 0x79, 0x00, 0xe0, 0xff, 0x7f, 0x80, 0xc1, 0x01, 0x03, 0xe0, 0x79,
   0x00, 0xe0, 0xff, 0x7f, 0x80, 0xc1, 0x81, 0x03, 0xe0, 0x79, 0x00, 0xe0,
   0xff, 0x7f, 0x80, 0xc3, 0x81, 0x03, 0xe0, 0x79, 0x00, 0x00, 0x00, 0x00,
   0x80, 0x83, 0xc3, 0x03, 0xe0, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x83,
   0xff, 0x01, 0xe0, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0x01,
   0xe0, 0x79, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0xe0, 0x79,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0xe0, 0x79, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x79, 0x00, 0x00, 0xf0, 0x7f,
   0x00, 0x00, 0x00, 0x00, 0xe0, 0x79, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00,
   0x00, 0x00, 0xe0, 0x79, 0x00, 0xc0, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00,
   0xe0, 0x79, 0x00, 0xc0, 0x7b, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x79,
   0x00, 0xe0, 0x30, 0x38, 0x8f, 0xff, 0xff, 0x03, 0xe0, 0x79, 0x00, 0xe0,
   0x30, 0x30, 0x8f, 0xff, 0xff, 0x03, 0xe0, 0x79, 0x00, 0x70, 0x30, 0x60,
   0x8f, 0xff, 0xff, 0x01, 0xe0, 0x79, 0x00, 0x70, 0x30, 0x60, 0x00, 0x00,
   0x00, 0x00, 0xe0, 0x79, 0x00, 0x70, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00,
   0xe0, 0x79, 0x00, 0x70, 0x30, 0xe0, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x79,
   0x00, 0x70, 0x30, 0xe0, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x79, 0x00, 0x60,
   0x70, 0x70, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x79, 0x00, 0x60, 0xf0, 0x70,
   0x00, 0x03, 0x80, 0x01, 0xe0, 0x79, 0x00, 0xe0, 0xe0, 0x7f, 0x00, 0x03,
   0x80, 0x01, 0xe0, 0x79, 0x00, 0xc0, 0xc0, 0x3f, 0x80, 0x03, 0x80, 0x03,
   0xe0, 0x79, 0x00, 0x00, 0x80, 0x1f, 0x80, 0x03, 0x80, 0x03, 0xe0, 0x79,
   0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x03, 0xe0, 0x79, 0x00, 0x00,
   0x00, 0x00, 0x80, 0x01, 0x00, 0x03, 0xe0, 0x79, 0x00, 0x00, 0x00, 0x00,
   0x80, 0x01, 0x00, 0x03, 0xe0, 0x79, 0x00, 0x60, 0x00, 0x60, 0x80, 0x03,
   0x80, 0x03, 0xe0, 0x79, 0x00, 0x60, 0x00, 0x60, 0x80, 0x03, 0x80, 0x03,
   0xe0, 0x79, 0x00, 0x60, 0x00, 0x60, 0x80, 0x07, 0xc0, 0x01, 0xe0, 0x79,
   0x00, 0x60, 0x00, 0x60, 0x00, 0x0f, 0xe0, 0x01, 0xe0, 0x79, 0x00, 0x60,
   0x00, 0x60, 0x00, 0x7e, 0xfc, 0x00, 0xe0, 0x79, 0x00, 0x60, 0x00, 0x70,
   0x00, 0xfc, 0x7f, 0x00, 0xe0, 0x79, 0x00, 0xff, 0xff, 0x7f, 0x00, 0xf8,
   0x3f, 0x00, 0xe0, 0x79, 0x00, 0xff, 0xff, 0x3f, 0x00, 0xe0, 0x0f, 0x00,
   0xe0, 0x79, 0x00, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x79,
   0x00, 0xfe, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x79, 0x00, 0x60,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x60, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0,
   0x1f, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00,
   0x00, 0x78, 0x00, 0x00, 0x00, 0x06, 0x00, 0xfe, 0xff, 0x00, 0x00, 0x78,
   0x00, 0xc0, 0x80, 0x1f, 0x00, 0x1f, 0xf0, 0x01, 0x00, 0x78, 0x00, 0xe0,
   0xc0, 0x3f, 0x00, 0x07, 0xc0, 0x01, 0xf8, 0xff, 0x7f, 0x60, 0xc0, 0x7b,
   0x80, 0x03, 0x80, 0x03, 0xf0, 0xff, 0x3f, 0x60, 0xe0, 0x70, 0x80, 0x03,
   0x80, 0x03, 0xf0, 0xff, 0x1f, 0x70, 0xe0, 0x60, 0x80, 0x01, 0x80, 0x03,
   0xe0, 0xff, 0x1f, 0x70, 0xe0, 0xe0, 0x80, 0x01, 0x00, 0x03, 0xc0, 0xff,
   0x0f, 0x70, 0x70, 0xe0, 0x80, 0x03, 0x80, 0x03, 0x80, 0xff, 0x07, 0x70,
   0x70, 0xe0, 0x80, 0x03, 0x80, 0x03, 0x80, 0xff, 0x07, 0x60, 0x70, 0x60,
   0x80, 0x07, 0xc0, 0x03, 0x00, 0xff, 0x03, 0xe0, 0x78, 0x60, 0x00, 0x0f,
   0xe0, 0x01, 0x00, 0xfe, 0x01, 0xe0, 0x3d, 0x60, 0x00, 0x3f, 0xf8, 0x01,
   0x00, 0xfc, 0x01, 0xc0, 0x3f, 0x70, 0x00, 0xfe, 0xff, 0x00, 0x00, 0xf8,
   0x00, 0x80, 0x1f, 0x70, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0x78, 0x00, 0x00,
   0x02, 0x30, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x80, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0,
   0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0x03,
   0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0xfe, 0xff, 0x07, 0xc0, 0xe1,
   0xff, 0x7f, 0xfc, 0x00, 0x00, 0xff, 0xff, 0x0f, 0xc0, 0xe3, 0xff, 0x7f,
   0x7c, 0x00, 0x00, 0xff, 0xff, 0x1f, 0xc0, 0xe1, 0xff, 0x7f, 0x7e, 0x00,
   0x80, 0xff, 0xff, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0xc0, 0x7f,
   0xc0, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0xc0, 0x3f, 0x80, 0x3f,
   0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0xc0, 0x1f, 0x00, 0x3f, 0x00, 0x00,
   0x00, 0x00, 0x3f, 0x00, 0xe0, 0x0f, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
   0x1f, 0x00, 0xe0, 0x0f, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00,
   0xe0, 0x07, 0x00, 0x7c, 0xc0, 0xff, 0xff, 0x7f, 0x1f, 0x00, 0xe0, 0x07,
   0x00, 0x7c, 0xc0, 0xff, 0xff, 0x7f, 0x1f, 0x00, 0xf0, 0x07, 0x00, 0x7c,
   0xc0, 0xff, 0xff, 0x7f, 0x1f, 0x00, 0xf0, 0x03, 0x00, 0x7c, 0x00, 0x80,
   0x07, 0x1e, 0x1f, 0x00, 0xf0, 0x03, 0x00, 0x7c, 0x00, 0xc0, 0x01, 0x38,
   0x1f, 0x00, 0xf0, 0x03, 0x00, 0xfc, 0x00, 0xe0, 0x00, 0x70, 0x1f, 0x00,
   0xf0, 0x03, 0x00, 0xfc, 0x00, 0x60, 0x00, 0x60, 0x1f, 0x00, 0xf8, 0x03,
   0x00, 0x7c, 0x00, 0x60, 0x00, 0x60, 0x1f, 0x00, 0xf8, 0x01, 0x00, 0x7c,
   0x00, 0x70, 0x00, 0xe0, 0x3f, 0x00, 0xf8, 0x01, 0x00, 0x7c, 0x00, 0x70,
   0x00, 0xe0, 0x3e, 0x00, 0xfc, 0x01, 0x00, 0x7c, 0x00, 0x70, 0x00, 0x60,
   0x7e, 0x00, 0xfc, 0x01, 0x00, 0x7c, 0x00, 0xe0, 0x00, 0x70, 0xfe, 0x00,
   0xfe, 0x00, 0x00, 0x7c, 0x00, 0xe0, 0x01, 0x78, 0xfc, 0x01, 0xff, 0x00,
   0x00, 0x7e, 0x00, 0xc0, 0x0f, 0x3f, 0xfc, 0xc7, 0x7f, 0x00, 0x00, 0x3e,
   0x00, 0x80, 0xff, 0x1f, 0xf8, 0xff, 0x7f, 0x00, 0x00, 0x3e, 0x00, 0x00,
   0xff, 0x0f, 0xf8, 0xff, 0x3f, 0x00, 0x00, 0x3f, 0x00, 0x00, 0xf8, 0x01,
   0xf0, 0xff, 0x3f, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xff,
   0x1f, 0x00, 0x80, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0x07, 0x00,
   0x80, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x80, 0x1f,
   0x00, 0x00, 0x00, 0x00 };

static unsigned char batteria_reverse_full_bits[] = {
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
   0x5f, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xaa,
   0xaa, 0xaa, 0xaa, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00,
   0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00,
   0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00,
   0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00,
   0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00,
   0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00,
   0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0xff, 0x7b, 0xef, 0xbd, 0xf7, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff };


static unsigned char batteria_reverse_34_bits[] = {
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
   0x5b, 0x00, 0x00, 0x00, 0x80, 0xfe, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xaa,
   0xaa, 0xaa, 0xaa, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00,
   0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00,
   0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00,
   0x7e, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00,
   0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x3e, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x3f, 0x00,
   0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7e, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00,
   0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x3e, 0x00,
   0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xdd, 0xdd, 0xdd, 0xbd, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff };


static unsigned char batteria_reverse__mezzo_bits[] = {
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
   0x5b, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0x7f, 0x55, 0x55, 0x55, 0x55, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00,
   0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x3e, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00,
   0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x3e, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00,
   0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x3e, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00,
   0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xbb, 0xbb, 0xbb, 0x7b, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff };

   static unsigned char batteria_reverse_14_bits[] = {
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff,
   0x56, 0x00, 0x00, 0x00, 0x00, 0xfd, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00,
   0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x7e, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x3f, 0x00,
   0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff,
   0xff, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00,
   0x7f, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x7f, 0x00,
   0x00, 0x00, 0x00, 0x7f, 0x80, 0xff, 0xff, 0x00, 0x7e, 0x00, 0x00, 0x00,
   0x00, 0x7e, 0x80, 0xff, 0xff, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x7e,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xee, 0xee, 0xee, 0xee, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xfe, 0xff,
   0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff,
   0xff, 0x7f, 0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f,
   0x80, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff,
   0xff, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff };

static unsigned char batteria_charge_bits[] = {
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbf, 0xaa, 0xaa, 0xaa,
   0xaa, 0xfa, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xf8,
   0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
   0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff,
   0x3f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
   0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00,
   0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xf8,
   0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
   0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff,
   0x3f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
   0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00,
   0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xf8,
   0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff,
   0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff,
   0x3f, 0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00,
   0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00,
   0x00, 0xf8, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
   0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
   0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0xc0, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0,
   0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xc0,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xc0, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0,
   0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xc0,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0x07, 0xe0, 0x0f, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0,
   0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xc0, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd, 0x07, 0xe0,
   0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x07, 0xe0, 0x0f, 0xe0,
   0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff,
   0xff, 0xff, 0x3f, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff,
   0x1f, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x8f, 0xff,
   0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0x87, 0xff, 0x07, 0xe0,
   0x0f, 0xc0, 0xff, 0xff, 0xff, 0xff, 0x83, 0xff, 0x07, 0xe0, 0x0f, 0xe0,
   0xff, 0xff, 0xff, 0xff, 0xc1, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff,
   0xff, 0xff, 0xc0, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0x7f,
   0xe0, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0x3f, 0xe0, 0xff,
   0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0x1f, 0xf0, 0xff, 0x07, 0xe0,
   0x0f, 0xe0, 0xff, 0xff, 0xff, 0x0f, 0xf0, 0xff, 0x07, 0xe0, 0x0f, 0xe0,
   0xff, 0xff, 0xff, 0x07, 0xf8, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff,
   0xff, 0x03, 0xf8, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0x01,
   0xfc, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0x00, 0xfc, 0xff,
   0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0x7f, 0x00, 0xfe, 0xff, 0x07, 0xe0,
   0x0f, 0xe0, 0xff, 0xff, 0x3f, 0x00, 0xfe, 0xff, 0x07, 0xe0, 0x0f, 0xe0,
   0xff, 0xff, 0x1f, 0x00, 0xfe, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff,
   0x0f, 0x00, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0x07, 0x00,
   0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0x03, 0x80, 0xff, 0xff,
   0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0x01, 0x80, 0xff, 0xff, 0x07, 0xe0,
   0x0f, 0xe0, 0xff, 0xff, 0x00, 0xc0, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0,
   0xff, 0x7f, 0x00, 0xc0, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0x3f,
   0x00, 0xe0, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0x1f, 0x00, 0xe0,
   0xaf, 0xf8, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0x0f, 0x00, 0x00, 0x00, 0xfc,
   0x07, 0xe0, 0x0f, 0xe0, 0xff, 0x07, 0x00, 0x00, 0x00, 0xfe, 0x07, 0xe0,
   0x0f, 0xe0, 0xff, 0x03, 0x00, 0x00, 0x00, 0xff, 0x07, 0xe0, 0x0f, 0xe0,
   0xff, 0x01, 0x00, 0x00, 0x80, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0x00,
   0x00, 0x00, 0xc0, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0x7f, 0x00, 0x00, 0x00,
   0xe0, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0x3f, 0xe8, 0x0f, 0x00, 0xf0, 0xff,
   0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0x0f, 0x00, 0xf8, 0xff, 0x07, 0xe0,
   0x0f, 0xe0, 0xff, 0xff, 0x07, 0x00, 0xfc, 0xff, 0x07, 0xe0, 0x0f, 0xe0,
   0xff, 0xff, 0x07, 0x00, 0xfe, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff,
   0x03, 0x00, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0x03, 0x80,
   0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0x01, 0xc0, 0xff, 0xff,
   0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0x01, 0xe0, 0xff, 0xff, 0x07, 0xe0,
   0x0f, 0xe0, 0xff, 0xff, 0x00, 0xf0, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0,
   0xff, 0xff, 0x00, 0xf8, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0x7f,
   0x00, 0xfc, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0x7f, 0x00, 0xfe,
   0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0x3f, 0x00, 0xff, 0xff, 0xff,
   0x07, 0xe0, 0x0f, 0xe0, 0xff, 0x3f, 0x80, 0xff, 0xff, 0xff, 0x07, 0xe0,
   0x0f, 0xe0, 0xff, 0x3f, 0xc0, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0,
   0xff, 0x1f, 0xe0, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0x1f,
   0xf0, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0x0f, 0xf8, 0xff,
   0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0x0f, 0xfc, 0xff, 0xff, 0xff,
   0x07, 0xe0, 0x0f, 0xe0, 0xff, 0x07, 0xfe, 0xff, 0xff, 0xff, 0x07, 0xe0,
   0x0f, 0xe0, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0,
   0xff, 0x83, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xc3,
   0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xe3, 0xff, 0xff,
   0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xf1, 0xff, 0xff, 0xff, 0xff,
   0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0,
   0x0f, 0xe0, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0,
   0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0x7f, 0xff,
   0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0,
   0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0,
   0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0,
   0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0x07, 0xe0, 0x0f, 0xe0, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0x07, 0xe0, 0x0f, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0x07, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
   0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0xe0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0,
   0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x2f, 0x49, 0x92, 0x24,
   0x49, 0x92, 0x24, 0x22, 0x91, 0xe4, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
   0xff, 0xff, 0xff, 0xff };

BLEServer* pServer = NULL;
BLECharacteristic* pCharacteristic = NULL;
bool deviceConnected = false;
bool oldDeviceConnected = false;
uint32_t value = 0;

#define SERVICE_UUID        "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"


class MyServerCallbacks: public BLEServerCallbacks {
    void onConnect(BLEServer* pServer) {
      deviceConnected = true;
    };

    void onDisconnect(BLEServer* pServer) {
      deviceConnected = false;
    }
};


class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
    void onResult(BLEAdvertisedDevice advertisedDevice) {
//      prova = 
      //Serial.printf("Advertised Device: %s \n", advertisedDevice.toString().c_str());
      
      //Serial.printf("%s : ",advertisedDevice.getAddress().toString().c_str());
      //Serial.printf("%s : ",advertisedDevice.getServiceUUID().toString().c_str());
      //Serial.printf("%i\n",advertisedDevice.getRSSI());
      
      String address = advertisedDevice.getAddress().toString().c_str();
      String name;
      if (advertisedDevice.haveName ())
            {
                name = advertisedDevice.getName().c_str();
                //Serial.printf("%s\n",name);
            }

      int rssi = advertisedDevice.getRSSI();
      if (name.equals("SocialDistance"))
        {
         //Serial.println(address);
         //Serial.println(rssi);
         //Serial.println("=="); 
            if (rssi > -55)
            {
                // Se e' vicino accende lo schermo di colore rosso
                M5.Axp.SetLDO2(true);
                //M5.Axp.SetLDO3(true);
                M5.Lcd.fillScreen(RED);
                // ed emette suono
                //ledcWriteTone(ledChannel, 1250);
                //delay(500);
                //ledcWriteTone(ledChannel, 0);
            }
            else
            {
                // turn off screen
                M5.Axp.SetLDO2(false);
                //M5.Axp.SetLDO3(false);
                //M5.Lcd.fillScreen(GREEN);
            }
        }
        
      
    }
};

// Non usata
void blink_led()
  {
    pinMode(M5_LED,OUTPUT);
    digitalWrite(M5_LED,HIGH);
    //delay(100);
    //digitalWrite(M5_LED,LOW);
    //delay(100);
  }


double getBatteryLevel(void)
{
  uint16_t vbatData = M5.Axp.GetVbatData();
  double vbat = vbatData * 1.1 / 1000;
  Serial.print("Livello Batteria % ");
  Serial.println(100.0 * ((vbat - 3.14) / (4.14 - 3.14)));
  //M5.Lcd.setCursor(0, 0);
  //M5.Lcd.println(vbat);
  return 100.0 * ((vbat - 3.14) / (4.14 - 3.14));
}

/*// genera il tono

void playMusic(const uint8_t* music_data, uint16_t sample_rate) {
  uint32_t length = strlen((char*)music_data);
  uint16_t delay_interval = ((uint32_t)1000000 / sample_rate);
    for(int i = 0; i < length; i++) {
      ledcWriteTone(ledChannel, music_data[i]*50);
      delayMicroseconds(delay_interval);
    } 
}*/

void setup() {
  M5.begin();  
  pinMode(M5_LED,OUTPUT);
  // al contrario di quanto si puo' pensare
  // LOW accende il LED mentre HIGH lo spenge
  digitalWrite(M5_LED,LOW);

  // Setup Speaker 
  //ledcSetup(ledChannel, freq, resolution);
  //ledcAttachPin(servo_pin, ledChannel);
  //ledcWrite(ledChannel, 256);//0°
  
  // mostra il logo
  M5.Lcd.fillScreen(WHITE);
  M5.Lcd.drawXBitmap (0, 0, logo_bits, batteria_reverse_width, batteria_reverse_height, TFT_BLACK); 
  delay(4000);
  M5.Axp.SetLDO2(false);
  //M5.Axp.SetLDO3(false);


  //M5.Lcd.setTextSize(2);


  //controllo della luminosita' dello schermo
  //per risparmiare energia (valori da 7 a 15)
  M5.Axp.ScreenBreath(15);


  M5.Axp.EnableCoulombcounter();

  Serial.begin(9600);
  //Serial.println("Scanning...");

  BLEDevice::init("SocialDistance");

  // Advertise
  pServer = BLEDevice::createServer();
  pServer->setCallbacks(new MyServerCallbacks());
  BLEService *pService = pServer->createService(SERVICE_UUID);
  pCharacteristic = pService->createCharacteristic(
                      CHARACTERISTIC_UUID,
                      BLECharacteristic::PROPERTY_READ   |
                      BLECharacteristic::PROPERTY_WRITE  |
                      BLECharacteristic::PROPERTY_NOTIFY |
                      BLECharacteristic::PROPERTY_INDICATE
                    );
  pCharacteristic->addDescriptor(new BLE2902());
  pService->start();
  BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
  pAdvertising->addServiceUUID(SERVICE_UUID);
  pAdvertising->setScanResponse(false);
  pAdvertising->setMinPreferred(0x0); 
  BLEDevice::startAdvertising();

  
  pBLEScan = BLEDevice::getScan(); //create new scan
  pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
  pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
  pBLEScan->setInterval(5000); // in millisecondi default 100
  pBLEScan->setWindow(2500);  // less or equal setInterval value default 99
}

void loop() {
  BLEScanResults foundDevices = pBLEScan->start(scanTime, false);
  //Serial.print("Devices found: ");
  //Serial.println(foundDevices.getCount());
  //Serial.println("Scan done!");
  pBLEScan->clearResults();   // delete results fromBLEScan buffer to release memory
  delay(1000);

  //controllo dello stato batteria
  // 4.1 V Full
  // 3.4 V Dead
  // 3.7 V Good
  //Serial.println(M5.Axp.GetBatVoltage());
  //controllo amper corrente
  //se negativo in scarica
  
  // Battery 
  //Serial.println("Battery Level "); 
  //Serial.println(getBatteryLevel());
  //Serial.print("Ampere ");
  //Serial.println(M5.Axp.GetBatCurrent());
  int bat = (int) getBatteryLevel();
  if (bat >= 99)
      {
          // la ricarica e' finita spenge il led
          digitalWrite(M5_LED,HIGH);
      }
      else
      {
          // altrimenti se e' in ricarica od in uso
          // tiene il led acceso 
          digitalWrite(M5_LED,LOW);
      }
      
  M5.update();
  // se si preme il tasto mette le informazioni sulla batteria
  if(M5.BtnA.wasPressed())
    {
                M5.Axp.SetLDO2(true);
                M5.Lcd.fillScreen(WHITE);
                if (bat > 100) bat = 100;
                if (M5.Axp.GetBatCurrent() > 0)
                    {
                     M5.Lcd.drawCentreString("Chg", 40, 10, 1);
                     M5.Lcd.drawXBitmap (0, 0, batteria_charge_bits, batteria_reverse_width, batteria_reverse_height, TFT_BLACK); 
                    }
                    else
                    {
                    M5.Lcd.drawCentreString(String(bat), 40, 10, 1);
                    if (getBatteryLevel() > 75)
                            M5.Lcd.drawXBitmap (0, 0, batteria_reverse_full_bits, batteria_reverse_width, batteria_reverse_height, TFT_BLACK); 
    
                    if ((getBatteryLevel() <= 75) && (getBatteryLevel() > 50))
                            M5.Lcd.drawXBitmap (0, 0, batteria_reverse_34_bits, batteria_reverse_width, batteria_reverse_height, TFT_BLACK); 
    
                    if ((getBatteryLevel() <= 50) && (getBatteryLevel() > 25))
                            M5.Lcd.drawXBitmap (0, 0,batteria_reverse__mezzo_bits , batteria_reverse_width, batteria_reverse_height, TFT_BLACK); 
                  
                    if (getBatteryLevel() <= 25)
                            M5.Lcd.drawXBitmap (0, 0, batteria_reverse_14_bits, batteria_reverse_width, batteria_reverse_height, TFT_BLACK); 
                    }
                delay(2000);
                M5.Axp.SetLDO2(false);
    }
}


Salutiamo il vecchio tema .....

... e diamo il benvenuto al Dark Theme



sabato 16 maggio 2020

ISS Docking

SpaceX ha reso pubblico un simulatore per il docking alla ISS e non potevo non provare


Non e' stato banalissimo piu' che altro per il controllo della velocita' anche perche' non ci sono istruzioni su tasti funzione

Le cose piu' divertenti sono gli easter eggs:
La modalita' Terra piatta




e la macchina Tesla che si trova ruotando la visuale all'indietro rispetto all'orientamento iniziale


giovedì 14 maggio 2020

MicroPython Bluetooth su Esp-Wroom-32

Ho provato a convertire la mia ESP32 DevKit V2 Esp-Wroom-32 per utilzzare Micropython



Per fare cio' per prima cosa si deve eliminare il firmware esistente

esptool.py --chip esp32 --port /dev/ttyUSB0 erase_flash

e poi flashare il firmware con MicroPython da questo link. Ne esistono due: il primo con il supporto completo indicato da V3 ed uno con il solo supporto BLE indicato da V4

esptool.py --chip esp32 --port /dev/ttyUSB0 write_flash -z 0x1000 /home/luca/Downloads/esp32-idf4-20191220-v1.12.bin 

Al termine, per vedere se ha funzionato si puo' aprire un terminale seriale come Minicom. Attenzione che devono disabilitati Hardware Flow e Software Flow

minicom -s
CTRL+A+Z
Serial Port Setup  115200 8N1 
Hardware Flow NO 
Software Flow NO

ci si trova davanti al prompt REPL di Python 

al posto di scrivere sulla shell tramite Minicom si puo' effettuare l'upload di un file tramite

pip install adafruit-ampy

per copiare un file sulla scheda si usa
ampy --port=/dev/ttyUSB0 put ble_advertising.py 

mentre per eseguirlo
ampy --port=/dev/ttyUSB0 run ble_advertising.py 

i comandi completi sono i seguenti

  get    Retrieve a file from the board.
  ls     List contents of a directory on the board.
  mkdir  Create a directory on the board.
  put    Put a file or folder and its contents on the board.
  reset  Perform soft reset/reboot of the board.
  rm     Remove a file from the board.
  rmdir  Forcefully remove a folder and all its children from the board.
  run    Run a script and print its output.

(questi codici erano gia' stati visti con M5Stack)

per avere gli esempi di MicroPython si puo' clonare

git clone https://github.com/micropython/micropython


un altro comodo sistema per gestire il dispotivo e' RShell con cui si puo' interagire con  il  file system


root@debian:~# rshell --buffer-size=30 -p /dev/ttyUSB0
Using buffer-size of 30
Connecting to /dev/ttyUSB0 (buffer-size 30)...
Trying to connect to REPL  connected
Testing if ubinascii.unhexlify exists ... Y
Retrieving root directories ... /boot.py/ /ble_temperature.py/ /advertise.py/ /socialdistance.py/ /ble_temperature_central.py/ /scan.py/
Setting time ... May 12, 2020 19:08:12
Evaluating board_name ... pyboard
Retrieving time epoch ... Jan 01, 2000
Welcome to rshell. Use Control-D (or the exit command) to exit rshell.
/root> 


gli script python si trovano nella directory /pyboard quindi basta fare 

cd /pyboard
ls

per osservarli 

edit nome_file.py

apre vi per permettere l'editing (l'editor non si trova sull'ESP32 ma sul computer)

per fare un scansione di dispositivi BLE con Micropython si puo' usare 

--------------------------------------------------------------------
import bluetooth
from micropython import const
import time

_IRQ_CENTRAL_CONNECT                 = const(1 << 0)
_IRQ_CENTRAL_DISCONNECT              = const(1 << 1)
_IRQ_GATTS_WRITE                     = const(1 << 2)
_IRQ_GATTS_READ_REQUEST              = const(1 << 3)
_IRQ_SCAN_RESULT                     = const(1 << 4)
_IRQ_SCAN_COMPLETE                   = const(1 << 5)
_IRQ_PERIPHERAL_CONNECT              = const(1 << 6)
_IRQ_PERIPHERAL_DISCONNECT           = const(1 << 7)
_IRQ_GATTC_SERVICE_RESULT            = const(1 << 8)
_IRQ_GATTC_CHARACTERISTIC_RESULT     = const(1 << 9)
_IRQ_GATTC_DESCRIPTOR_RESULT         = const(1 << 10)
_IRQ_GATTC_READ_RESULT               = const(1 << 11)
_IRQ_GATTC_WRITE_STATUS              = const(1 << 12)
_IRQ_GATTC_NOTIFY                    = const(1 << 13)
_IRQ_GATTC_INDICATE                  = const(1 << 14)


def bt_irq(event, data):
    if event == _IRQ_SCAN_RESULT:
        addr_type, addr, connectabt, rssi, adv_data = data
        print(data)
       
    elif event == _IRQ_SCAN_COMPLETE:
        print("scan complete")

bt = bluetooth.BLE()
bt.active(True) 
bt.gap_scan(10000, 10000, 10000)
bt.irq(bt_irq)

time.sleep(20)

--------------------------------------------------------------------

per creare un dispositivo che fa solo l'advertise in BLE

---------------------------------------------------------------------
import bluetooth
import struct
import time
from ble_advertising import advertising_payload
from micropython import const

_ENV_SENSE_UUID = bluetooth.UUID(0x181A)
_ADV_APPEARANCE_GENERIC_THERMOMETER = const(768)


class BLETemperature:
    def __init__(self, ble, name="SocialDistance"):
        self._ble = ble
        self._ble.active(True)
        self._payload = advertising_payload(
            name=name, services=[_ENV_SENSE_UUID], appearance=_ADV_APPEARANCE_GENERIC_THERMOMETER
        )
        self._advertise()
    def _advertise(self, interval_us=500000):
        self._ble.gap_advertise(interval_us, adv_data=self._payload)


def demo():
    ble = bluetooth.BLE()
    temp = BLETemperature(ble)
    while True:
print("Sociale")

if __name__ == "__main__":
    demo()
---------------------------------------------------------------------


martedì 12 maggio 2020

Damn Vulnerable Web Application

Mi sto leggendo avanza tempo il libro HackLog  Manuale di Sicurezza Informatica ed Hacking Etico di Stefano Novelli. Nel libro viene  DVWA - Damn Vulnerable Web Application, una applicazione web studiata appositamente per fare pratica con le vulnerabilita' principalmente di webserver

Si puo' ottenere la DVWA da questo link in formato iso o docker. Ho scelto la ISO ma ho scoperto su Debian Testing VirtualBox non ne vuole sapere di installarsi....sono passato a QEmu

qemu-system-x86_64 -cdrom  DVWA-1.0.7.iso -m 2G -enable-kvm -net user,hostfwd=tcp::8080-:80 -net nic

a questo punto basta puntare il browser su  http://localhost:8080/login.php con credenziali admin/password



Di esempi ce ne sono tanti ma molto semplici ad impegnativi.

domenica 19 aprile 2020

QTCustomPlot da dati CSV

Un progettino semplice per graficare dati derivanti da un file CSV (si tratta di un progetto satellite di un progetto Android con cui, tramite applicazione, vengono salvati i dati di accelerazione)



Come libreria per plottare i dati ho usato QTCustomPlot per la semplicita' di zoom/pan mentre per la lettura di CSV e' stata impiegata QtCSV

Il codice e' disponibile su GitHub. E' possibile zoom/pan ed avere le coordinate del puntatore

Per impostare QTCustomPlot su QtCreator si devono imporate i file qtcustomplot.cpp/ qtcustomplot.h, si aggiunge al file .pro  QT += printsupport, si trascina sul form un QWidget, tasto destro Promote To e si fa il promote a QtCustomPlot (il metodo e' cambiato rispetto al precedente post https://debiaonoldcomputers.blogspot.com/2013/11/software-per-progetto-force-gauge.html)

======================================================
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "qcustomplot.h"

#include "variantdata.h"
#include "reader.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QString filePath = "/home/luca/ss/7.csv";

    QList<QStringList> readData = QtCSV::Reader::readToList(filePath,";");

    QVector<double> x(readData.size()), y(readData.size());

    //l.resize(readData.size());

  for ( int i = 0; i < readData.size(); ++i )
  {
      x[i] = readData.at(i).value(1).toDouble()-1587149254484;
      y[i] = readData.at(i).value(2).toDouble();

  }
   //Abilita Drag e Zoom
    ui->customPlot->setInteraction(QCP::iRangeDrag,true);
    ui->customPlot->setInteraction(QCP::iRangeZoom,true);


    ui->customPlot->addGraph();
    ui->customPlot->graph(0)->setData(x,y);
    ui->customPlot->graph(0)->setBrush(QBrush(QColor(0, 0, 255, 20)));
    ui->customPlot->graph(0)->setPen(QPen(Qt::blue));
    connect(ui->customPlot,SIGNAL(mousePress(QMouseEvent *)),SLOT (clickedGraph(QMouseEvent*)));
    connect(ui->customPlot,SIGNAL(mouseMove(QMouseEvent *)),SLOT (MouseGraph(QMouseEvent*)));

    ui->customPlot->addGraph();

    ui->customPlot->xAxis->setLabel("Time");
    ui->customPlot->yAxis->setLabel("Acc");

    //double x_min = *std::min_element(x.constBegin(), x.constEnd());
    //double x_max = *std::max_element(x.constBegin(), x.constEnd());
    //double y_min = *std::min_element(y.constBegin(), y.constEnd());
    //double y_max = *std::max_element(y.constBegin(), y.constEnd());
    //ui->customPlot->xAxis->setRange(x_min, x_max);
    //ui->customPlot->yAxis->setRange(y_min, y_max);

    ui->customPlot->rescaleAxes();
    ui->customPlot->replot();
    //qDebug() << ui->customPlot->xAxis->pixelToCoord(mouseEvent->pos().x()) << ui->customPlot->yAxis->pixelToCoord(mouseEvent->pos().y());
}

void MainWindow::clickedGraph(QMouseEvent *event)
{
    QPoint point = event->pos();
    qDebug() << ui->customPlot->xAxis->pixelToCoord(point.x());
    qDebug() << ui->customPlot->yAxis->pixelToCoord(point.y());

}

void MainWindow::MouseGraph(QMouseEvent *event)
{
    QPoint point = event->pos();
    qDebug() << ui->customPlot->xAxis->pixelToCoord(point.x());
    qDebug() << ui->customPlot->yAxis->pixelToCoord(point.y());

    QVariant xi = ui->customPlot->xAxis->pixelToCoord(point.x());
    QVariant yi = ui->customPlot->yAxis->pixelToCoord(point.y());

    ui->xmouse->setText(xi.toString());
    ui->ymouse->setText(yi.toString());


}


MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_horizontalSlider_valueChanged(int value)
{
}

lunedì 13 aprile 2020

Millenium Falcon

Passatempo da quarantena....comprato due anni fa ma mai avuto il tempo nemmeno di iniziarlo





Da Arduino ad Internet tramite Android

Avevo la necessita' di collegare una Arduino Nano 33 BLE ad internet ma non avevo molte idee quando ho pensato di usare come ponte un telefono Android

La Arduino e' contenuta nella scatolina bianca 

Per leggere i dati della porta seriale di Arduino ho collegato un cavo OTG alla USB di Android usando la libreria https://github.com/felHR85/UsbSerial. I dati poi sono stati inviati in HTTP Get tramite OKHttp. Il progetto della applicazione Android si trova sul mio GitHub https://github.com/c1p81/Seriale (si tratta di una modifica dell'esempio della libreria UsbSerial)

Questo e' invece lo skecth Arduino

=========================================================
#include <Arduino_LSM9DS1.h>
#include <Arduino_HTS221.h>
#include <Arduino_LPS22HB.h>
#include <Arduino_APDS9960.h>

int conteggio;

void setup() {
  conteggio = 0;
  Serial.begin(9600);
  while (!Serial);

  if (!IMU.begin()) {
    Serial.println("Failed to initialize IMU!");
    while (1);
  }

  if (!HTS.begin()) {
    Serial.println("Failed to initialize humidity temperature sensor!");
    while (1);
  }

  
  if (!BARO.begin()) {
    Serial.println("Failed to initialize pressure sensor!");
    while (1);
  }

   if (!APDS.begin()) {
    Serial.println("Error initializing APDS9960 sensor.");
  }

}

void loop() {
  float  x, y, z;
  double dx,dy,dz;
  double mx,my,mz;
  double fx,fy,fz;
  double pitch,roll = 0.0;
  double mpitch,mroll = 0.0;
  const float alpha = 0.5;

  float pressure = BARO.readPressure();
  float temperature = HTS.readTemperature();
  float humidity    = HTS.readHumidity();

   while (! APDS.colorAvailable()) {
    delay(5);
  }
  int r, g, b, light_int;

  APDS.readColor(r, g, b, light_int);

  

  if (IMU.accelerationAvailable()) {
    IMU.readAcceleration(x, y, z);
    dx = (double)x;
    dy = (double)y;
    dz = (double)z;
    
    mx = mx + dx;
    my = mx + dy;
    mz = mx + dz;
    
    fx = (dx*alpha) + (fx*(1-alpha));
    fy = (dy*alpha) + (fy*(1-alpha));
    fz = (dz*alpha) + (fz*(1-alpha));

    conteggio++;
  }

  if (conteggio > 10000)
      {
        mx = mx /conteggio;
        my = my /conteggio;        
        mz = mz /conteggio;
        
        roll = atan2(fy,fz)*57.29577;
        pitch = atan2(-fx,sqrt((fy*fy)+(fz*fz)))*57.29577;

        mroll = atan2(my,mz)*57.29577;
        mpitch = atan2(-mx,sqrt((my*my)+(mz*mz)))*57.29577;

        Serial.println(String(mpitch)+";"+String(mroll)+";"+String(pitch)+";"+String(roll)+";"+String(temperature)+";"+String(humidity)+";"+String(pressure)+";"+String(light_int));
        conteggio = 0;
        fx = fy = fz = 0;
        mx = my = mz = 0;
      
      }

  
  delay(10);
  //delay(5000);
}

=========================================================
I dati sono plottati sul server mediante JSCanvas. Gli script si trovano qui https://github.com/c1p81/Seriale/tree/master/app/seriale_html













venerdì 10 aprile 2020

Trasmissione dati con ultrasuoni

Leggendo le caratteristiche di Arduino Nano 33 BLE ho scoperto che era compatibile con la trasmissione dati via ultrasuoni tramite le librerie CHIRP. La ditta pero' e' stata acquisita da Sonos e non e' piu' possibile usare le librerie per l'impossibilita' di acquisire la API KEY.

Ho scoperto che si puo' fare qualche test anche con un semplice browser (meglio Chrome) usando le librerie Quiet JS puntando a questa pagina https://quiet.github.io/quiet-js/


La cosa divertente e' che mio figlio di 10 anni sente distintamente la frequenza agli ultrasuoni mentre io no (questa predisposizione dei bambini a sentire gli ultrasuoni l'ho vista usare da un prestigiatore per un trucco magico che prevedeva la collaborazione del figlio..... in pratica il figlio indovinava sempre la carta nascosta ma solo perche' il padre con emettitore indicava il valore della carta con un codice condiviso)

QML Mandelbrot in UBPorts / Ubuntu Touch (2)

Avevo gia' provato qui a creare l'insieme di Mandelbrot su UBPorts in QML ma il programma era scandalosamente lento ed ho provato a migliorare


In questo codice il risultato di calcolo per ogni pixel viene salvato in un array imgData che poi 
trasferito in un colpo sul Canvas. In questo modo il tempo di calcolo e' divenuto inferiore ad un terzo di quello della precedente prova

==============================================================
/*
 * Copyright (C) 2020  Luca Innocenit
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 3.
 *
 * ubuntu-calculator-app is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import QtQuick 2.7
import Ubuntu.Components 1.3
//import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import Qt.labs.settings 1.0
import QtQuick.Window 2.2

MainView {
    id: root
    objectName: 'mainView'
    applicationName: 'qtcpp.com.luca.innocenti'
    automaticOrientation: true

    visible: true
      width: Screen.width
      height: Screen.width
      Canvas {
          id: mycanvas
          anchors.centerIn: parent
          width: Screen.width
          height: Screen.width
          onPaint: {
              console.log("width "+ width.toString())
              console.log("height "+ height.toString())

              var ctx = getContext("2d");
              ctx.fillStyle = Qt.rgba(0, 0, 0, 1);
              ctx.fillRect(0, 0, width, height);
              var imgData = ctx.createImageData(height, width);

              ////////
              var re_min = -2.0;
             var im_min = -1.2;
             var re_max = 0.7;
             var im_max = 1.2;
             var iterazioni = 50;

             var r;
             var a,b;
             var x,y,x_new,y_new;
             var test;
             var re_factor = (re_max-re_min);
             var im_factor = (im_max-im_min);
             var indice = 0;

              for (var i=0;i<width;i++)
                          {
                          for (var j=0;j<height;j++)
                           {
                               a = re_min+(j*re_factor/height);
                               b = im_min+(i*im_factor/width);
                               x = 0;
                               y = 0;
                               test = 0;
                              imgData.data[indice+3]= 255;
                              //console.log(indice)

                               for (var k=0;k<iterazioni;k++)
                                    {
                                    x_new = (x*x)-(y*y)+a;
                                    y_new = (2*x*y)+b;
                                    if (((x_new*x_new)+(y_new*y_new))>4)
                                          {
                                            if (k%2)
                                                {
                                                  // colora il punto
                                                  imgData.data[indice]=255;
                                                  imgData.data[indice+1]=255;
                                                  imgData.data[indice+2]=255;  
                                                }

                                            break;
                                          }
                                    x = x_new;
                                    y = y_new;
                                    }
                               indice = indice + 4;
                           }
              }
              ///////
              console.log("terminato")
              ctx.drawImage(imgData, 0, 0);

          }
      }
}

giovedì 9 aprile 2020

Alpine su Getac M230

Volevo ridare vita a questo GETAC M230, una macchina con un core duo. Il problema e' che questa macchina non ha una porta ethernet (c'e' una scheda di rete per fibra ottica) e non volevo impazzire a caricare i driver da USB della WiFi in fase di installazione come accade per Debian

Ho provato prima una LUbuntu che oggettivamente ha reso la macchina inservibile. Sono passato quindi ad Alpine Linux i386 che ha riconosciuto la scheda WiFi al volo

Avevo gia' configurato una Alpine 

apk add wireless-tools wpa_supplicant



Ingresso fibra ottica



apk add wireless-tools wpa_supplicant

Uno dei problemi e' che al riavvio non viene agganciato l'accesso point al boot.
Ogni volta devo rilanciare questi comandi per ottenre la connessione di rete

wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant_wpa_supplicant.conf
udhcpc -i wlan0


Per montare i3 window manager si devono aggiungere i pacchetti

apk add i3wm
apk add i3lock i3status
apk add xterm

e si edita il file  .xinitrc
==========================
DEFAULT=13
[ -n $1 ]  && 1
exec ${DEFAULT}
==========================
I3 funziona al meglio in modalita' tabbed

Per avere il controllo della batteria si deve aggiungere il supporto ACPI

apk add acpi


Firefox si installa e funziona ma freeza spesso
Non e' presente Emacs per X, c'e' solo per la consolle in quanto il sistema e' basato su uclib e non glibc. In compenso c'e' una vetusta versione di Qt/ Qt Creator


Per spengere la macchina si deve digitare

poweroff

mercoledì 8 aprile 2020

Android Studio WiFi Adb Plugin

Per programmare con Adb via WiFi si puo' fare in vari modi

Usando un plugin (la via piu' comoda) si puo' installare un plugin di Android Studio da File/Settings/Plugins e scegliendo per esempio Android WiFi ADB


Si aggiungera' una icona (in verde chiaro al centro nell'immagine successiva)


Si collega il telefono via USB agganciandosi alla stessa WiFi del portatile. Si clicca sull'icona, si attende la connessione e successivamente si puo' disconnettere il cavo USB

Altrimenti da shell si possono inviare i seguenti comandi

A cavo USB attaccato si digita

adb shell setprop service.adb.tcp.port 4444
adb tcpip 4444
adb connect ip_telefono:4444

OkHttp per Android

Per utilizzare chiamate HTTP in un progetto Android basato su Java (per Kotlin una libreria comoda e' Fuel ) si puo' utilizzare OKHttp anche se e' cosi' immediato utilizzarla

Per aggiungere la libreria al progetto si edita build.gradle(progetto) aggiugendo la riga in giallo

allprojects {    repositories {        google()
        jcenter()
        maven { url "https://jitpack.io" }            }}

e si aggiunge la libreria indicata dalla riga in giallo

dependencies {    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.appcompat:appcompat:1.1.0'    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'    testImplementation 'junit:junit:4.12'    androidTestImplementation 'androidx.test.ext:junit:1.1.1'    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.github.felHR85:UsbSerial:6.1.0'    implementation("com.squareup.okhttp3:okhttp:4.5.0")}


Per prima cosa si aggiunge il permesso di accesso ad Internet nel Manifest

<uses-permission android:name="android.permission.INTERNET" />

In seguito si crea un directory xml in res e si crea un nuovo file XML denominato network_security_config.xml con i permessi di accesso alla rete




Per esempio qui si abilita il traffico HTTP (HTTPS e' default) verso tutti i domini
network_security_config.xml
-----------------------------------------
<?xml version="1.0" encoding="utf-8"?><network-security-config xmlns:android="http://schemas.android.com/apk/res/android">    <base-config cleartextTrafficPermitted="true" />
</network-security-config>
-----------------------------------------

Si torna al Manifest e si aggiunge la riga in giallo
<application    android:allowBackup="true"    android:icon="@mipmap/ic_launcher"    android:label="@string/app_name"    android:networkSecurityConfig="@xml/network_security_config"    android:roundIcon="@mipmap/ic_launcher_round"    android:supportsRtl="true"


il metodo standard per implementare la chiamata e' creare una classe

public static class senddata {
    OkHttpClient client = new OkHttpClient();
    String run(String url) throws IOException {
        Request request = new Request.Builder()
                .url(url)
                .build();
        try (Response response = client.newCall(request).execute()) {
            return response.body().string();        }
    }
}


e poi chiamare il metodo per esempio in GET

senddata invio = new senddata();try {
    String response = invio.run("http://XXX.XXXX.XXX.XXX/seriale/index.php?stringa="+data.toString()+"&batteria="+percentage);} catch (IOException e) {
    e.printStackTrace();}

sabato 4 aprile 2020

Deriva termica su accelerometri MEMS

Stavo registrando dati con il telefono usando questa mia applicazione quando mi sono accorto che i dati non erano piu' stabili ma avevano una deriva. Rispetto alle prove precedenti stavo registrando usando come alimentazione del cellulare un pannello solare


Questi sono i grafici di pitch e roll in funzione del tempo. Come si vede i dati sono sincronizzati e seguono il ciclo diurno o meglio quello della temperatura (la prova e' durata tre giorni e nel giorno centrale era nuvoloso ed il minimo e' appena accennato)




Si tratta quindi di una deriva termica. Non avendo sul Nexus 5 un termometro (ho provato a loggare di dati del termometro della batteria ma sono dati completamente inutili con temperatura di 29 gradi C con una temperatura ambiente sempre inferiore ai 20 C)

C'e' un sistema semplice per ripulire la deriva termica e vedere se il telefono sta ruotando un pitch/roll o se e' solo l'effetto della temperatura

Tenendo il telefono fermo e plottando pitch vs roll si vede che le due misure sono fortemente correlate


il valore di R2 di correlazione e' di circa 0.8 (quindi abbastanza scarso) con una equazione

roll = 0.36pitch + 1.53

a questo punto si puo' calcolare, tramite questa formula, la distanza di ogni punto dalla retta di regressione. La distanza massima dei punti in condizioni statiche e' pari a 0.081 
Se la distanza di un punto, indipendentemente dalla temperatura, e' superiore al valore sopra riportato e' molto probabile che sia uno spostamento significativo e non una deriva termica

Per completezza questo e' il grafico in cui in ascisse ci sono i minuti da inizio ricarica solare ed in ordinata la percentuale di carica del telefono


giovedì 2 aprile 2020

JSON con GSON e Kotlin

Per leggere un file Json con Kotlin si puo' utilizzare la libreria GSON aggiungendo il gradle.build la seguente linea
implementation 'com.google.code.gson:gson:2.8.6'
facciamo per esempio che il file JSON ha il seguente tracciato

    val json = "{'cicli':26,'soglia': 1.5}"
si deve creare una classe che ricostruisce il tracciato record e crea dei metodi per leggere le proprieta'
class imposta(
var cicli:Int = 0,
var soglia:Float = 0.0f) {
fun Get_cicli():Int {
return cicli
}

fun Get_soglia():Float {
return soglia
}
override fun toString(): String {
return "${this.cicli}, ${this.soglia}"
}
}

dopo si cio' si puo' chiamare la funzione .fromJson per poter popolare le variabili
override fun onCreate(savedInstanceState: Bundle?) {
...........

val json = "{'cicli':26,'soglia': 1.5}"


var impostazioni = Gson().fromJson(json, imposta::class.java)
var prova = impostazioni.Get_cicli()
Log.d(
"imposta", impostazioni.toString())
Log.d(
"imposta", prova.toString())



LLama3 Anita

A seguito di questo post ho provato a vedere ho provato a vedere cosa accadeva ad utilizzare un modello specifico per la lingua italiana in...