Hola,
la verdad es que después de muchas pruebas (y de llegar a la conclusión de que uno de los paneles estaba estropeado porque me hacía una línea blanca), conseguí que me funcionara con la librería que venía en el ejemplo del pong.
#include <ht1632c.h> // Holtek LED driver by WestFW - updated to HT1632C by Nick Hall
Este es el encabezado del scketch
/***********************************************************************
* LED Pong Clock by Nick Hall
* v2.27 Dec 2010
Ojo, porque hay varias versiones de estos paneles controlados por un chip diferente (unos llevan la C y los otros no). he estado buscando los ficheros, la verdad es que núnca acabé este proyecto con los paneles monocromos, porque cuando vi que funcionaba continué con dos paneles de color, que utilizan otra librería diferente.
Tuve muchos problemas con la primera y con la segunda librería, complicados con la poca fiabilidad de estos paneles que a veces provocan que lo que piensas que es un error de programación sea un error del panel.
inserto a continuación una copia de mi scketch, es una versión bastante primitiva, poco documentada, desordenada, etc. aunque funciona. Lo siento
#include <ht1632c.h> // Holtek LED driver by WestFW - updated to HT1632C by Nick Hall
#include <avr/pgmspace.h> // Enable data to be stored in Flash Mem as well as SRAM
#include <Font.h> // Font library
#define ASSERT(condition) // Nothing
#define X_MAX 47 // Matrix X max LED coordinate (for 2 displays placed next to each other)
#define Y_MAX 15 // Matrix Y max LED coordinate (for 2 displays placed next to each other)
#define NUM_DISPLAYS 2 // Num displays for shadow ram data allocation
#define FADEDELAY 40 // Time to fade display to black
#define plot(x,y,v) ht1632_plot(x,y,v) // Plot LED
#define cls ht1632_clear // Clear display
static const byte ht1632_data = 10; // Data pin for sure module
static const byte ht1632_wrclk = 11; // Write clock pin for sure module
static const byte ht1632_cs[2] = {4,5}; // Chip_selects one for each sure module. Remember to set the DIP switches on the modules too.
String ProductId;
//____________________NEWSOFTSERIAL (SOLO PARA DEPURAR)_____________________________
#include <NewSoftSerial.h>
uint8_t ssRX = 9; // Connect Arduino pin 9 to TX of usb-serial device
uint8_t ssTX = 8;// Connect Arduino pin 8 to RX of usb-serial device
NewSoftSerial nss(ssRX, ssTX);
int cuentas =0;
int cuentasZB =0;
//__________________________________XBEE____________________________________________
#include <XBee.h> //Librería Xbeee
#define MAX_PAYLOAD_SIZE 72
XBee xbee = XBee(); //Crea el objeto de Xbee
uint8_t payload[MAX_PAYLOAD_SIZE]; //Crea el puntero para el payload
XBeeAddress64 addr64 = XBeeAddress64(0x00000000, 0x00000000);
ZBTxRequest zbTx = ZBTxRequest(addr64, payload, sizeof(payload));
ZBTxStatusResponse txStatus = ZBTxStatusResponse();
// create reusable response objects for responses we expect to handle
ZBRxResponse rx = ZBRxResponse();
ModemStatusResponse msr = ModemStatusResponse();
String pzb; //Contiene la cadena que se va a enviar en el payload
int statusLed = 13;
int errorLed=13;
int puntos=0;
long milesimas=0;
void setup()
{
xbee.begin(9600);
// Solo depuración
nss.begin(9600);
nss.println("Se ha reiniciado el micro!!");
// nss.println (cf.ProductId);
//********************************PANEL**************************************************
ht1632_setup(); // Setup display (uses flow chart from page 17 of sure datasheet)
ProductId="BMOTES PANEL";
ht1632_clear();
for (int n=0; n<=ProductId.length(); n++){
ht1632_puttinychar( n*4, 1, ProductId[n]);
}
delay (2000);
fade_down();
ht1632_clear();
fade_up();
}
//_________________________________BUCLE PRINCIPAL DEL PROGRAMA________________________________________
void loop()
{
xbee.readPacket(); //lee el paquete
//*****DEBUG*****
cuentasZB += 1;
if (cuentasZB>2000){
cuentasZB=0;
nss.print ("#");
}
//****************
if (xbee.getResponse().isAvailable()) //Si se ha recibido.....
{
nss.println ("Se ha recibido un paquete");
if (xbee.getResponse().getApiId() == ZB_RX_RESPONSE)
{ //Comprueba que se trate de un paquete ZB RX
xbee.getResponse().getZBRxResponse(rx); //rellena la clase ZB RX
borrarPayload();
String comando;
for (int n=0; n<=rx.getDataLength(); n++)
{
payload[n] = rx.getData()[n];
comando += rx.getData()[n];
}
if (comando.substring (0, 4)=="INF:")//Se ha enviado un comando al panel
{
procesarInfo (comando);
nss.println ("Despues de procesar info");
}
if (comando.substring (0, 4)=="HOR:") //Se ha enviado un comando de hora
{
procesarHora (comando);
nss.println ("Despues de procesar hora");
}
}
}
if (millis()-milesimas >1000)
{
int pos=22;
if (puntos==0)
{puntos=1;
ht1632_plot (pos, 6, 1);
ht1632_plot (pos, 7, 1);
ht1632_plot (pos+1, 6, 1);
ht1632_plot (pos+1, 7, 1);
ht1632_plot (pos, 10, 1);
ht1632_plot (pos, 11, 1);
ht1632_plot (pos+1, 10, 1);
ht1632_plot (pos+1, 11, 1);
}
else
{puntos=0;
ht1632_plot (pos, 6, 0);
ht1632_plot (pos, 7, 0);
ht1632_plot (pos+1, 6, 0);
ht1632_plot (pos+1, 7, 0);
ht1632_plot (pos, 10, 0);
ht1632_plot (pos, 11, 0);
ht1632_plot (pos+1, 10, 0);
ht1632_plot (pos+1, 11, 0);
}
milesimas = millis();
}
} //Fin del loop
//_______________________PROCESAR INFO____________________________________________________
void procesarInfo (String cmd){
int a, b, c;
String nodo, canal, valor, unidad;
int pos;
char car;
fade_down();
nss.println ("Despues de fade_down()");
ht1632_clear();
nss.println ("Despues de ht1632_clear()");
fade_up();
nss.println ("Despues de fadeup");
// Separa los valores en diferentes variables
a= cmd.indexOf(';');
if (a== -1)
{nodo=' ';
canal=' ';
valor=' ';}
else
{
nodo = cmd.substring (4,a);
b= cmd.indexOf(';', a+1);
if (b== -1)
{canal=' ';
valor=' ';}
else
{canal = cmd.substring (a+1,b);
c= cmd.indexOf(';', b+1);
if (c== -1)
{valor=' ';}
else
{valor = cmd.substring (b+1,c);}
}
}
unidad = cmd.substring (c+1);
if (nodo.length()>8) {nodo=nodo.substring(0,8);}
if (canal.length()>8) {canal=canal.substring(0,8);}
if (valor.length()>8) {valor=valor.substring(0,8);}
//Muestra en pantalla el nodo y el canal
pos= 0;
for (int n=0; n<nodo.length(); n++)
{
ht1632_putchar(pos, 0, nodo[n]);
pos +=6;
nss.print (nodo[n]);
}
pos= 0;
for (int n=0; n<canal.length(); n++)
{
ht1632_putchar( pos, 8, canal[n]);
pos +=6;
nss.print (canal[n]);
}
//espera 3 segundos
delay (3000);
fade_down();
nss.println ("Despues de fade_down()");
ht1632_clear();
nss.println ("Despues de ht1632_clear()");
fade_up();
nss.println ("Despues de fadeup");
pos= 0;
for (int n=0; n<valor.length(); n++)
{
car= valor[n];
switch (car)
{
case '.':
ht1632_plot (pos, 13, 1);
ht1632_plot (pos, 14, 1);
ht1632_plot (pos+1, 13, 1);
ht1632_plot (pos+1, 14, 1);
pos +=3;
break;
case ',':
ht1632_plot (pos, 13, 1);
ht1632_plot (pos, 14, 1);
ht1632_plot (pos+1, 13, 1);
ht1632_plot (pos+1, 14, 1);
pos +=3;
break;
case '1':
ht1632_putbigchar( pos, 1, valor[n]);
pos +=9;
break;
default:
ht1632_putbigchar( pos, 1, valor[n]);
pos +=11;
}
nss.print (canal[n]);
}
delay (3000);
}
//_______________________PROCESAR HORA____________________________________________________
void procesarHora (String cmd)
{
int pos=0;
ht1632_clear();
for (int n=4; n<6; n++)
{
ht1632_putbigchar( pos, 1, cmd[n]);
pos +=11;
}
ht1632_plot (pos, 6, 1);
ht1632_plot (pos, 7, 1);
ht1632_plot (pos+1, 6, 1);
ht1632_plot (pos+1, 7, 1);
ht1632_plot (pos, 10, 1);
ht1632_plot (pos, 11, 1);
ht1632_plot (pos+1, 10, 1);
ht1632_plot (pos+1, 11, 1);
pos +=3;
for (int n=7; n<9; n++)
{
ht1632_putbigchar( pos, 1, cmd[n]);
pos +=11;
}
}
http://www.zigbe.net/