Now I have changed Guzunty Pi's demo program to just display 4 digits.
// Display Guzunty Pi LED digits 0123 for 4 seconds - tlfong01 2013apr21
#include <unistd.h>
#include <gz_clk.h>
#include <gz_spi.h>
const unsigned char font[128] =
{
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // All
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // unprintable
0x00, 0x30, 0x22, 0x76, // SP, !, ", # (H)
0x6d, 0x7f, 0x7d, 0x20, // $ (5), % (8), & (6), '
0x39, 0x0f, 0x76, 0x76, // (, ), * (H), + (H)
0x10, 0x40, 0x00, 0x52, // ',', -, ., /
0x3f, 0x06, 0x5b, 0x4f, // 0, 1, 2, 3
0x66, 0x6d, 0x7d, 0x07, // 4, 5, 6, 7
0x7f, 0x6f, 0x30, 0x30, // 8, 9, :, ;
0x58, 0x48, 0x4c, 0x53, // <, =, >, ?
0x7b, 0x77, 0x7f, 0x39, // @, A, B, C
0x3f, 0x79, 0x71, 0x3d, // D (0), E, F, G
0x76, 0x06, 0x1e, 0x75, // H, I (1), J, K
0x38, 0x55, 0x37, 0x3f, // L, M, N, O (0)
0x73, 0x7d, 0x31, 0x6d, // P, Q, R, S (5)
0x07, 0x3e, 0x2a, 0x6a, // T, U, V, W
0x76, 0x6e, 0x5b, 0x39, // X (H), Y (y), Z, [
0x64, 0x0f, 0x23, 0x08, // backslash, ], ^, _
0x02, 0x77, 0x7c, 0x58, // ', a (A), b, c
0x5e, 0x7b, 0x71, 0x6f, // d, e, f (F), g
0x74, 0x04, 0x0c, 0x75, // h, i (1), j, k (K)
0x06, 0x55, 0x54, 0x5c, // l, m (M), n, o
0x73, 0x67, 0x50, 0x6d, // p (P), q, r, s (5)
0x78, 0x1c, 0x1c, 0x6a, // t, u, v (u), w (W)
0x76, 0x6e, 0x5b, 0x39, // x (H), y, Z (2), { ([)
0x30, 0x0f, 0x01, 0x00 // |, } (]), ~, DEL
};
int main()
{
gz_clock_ena(GZ_CLK_5MHz, 0xfff); // Turn on the slowest clock we can
unsigned char digitList[4];
gz_spi_set_width(4); // Pass blocks of 4 bytes on SPI
digitList[0] = ~0x3f; //'0'
digitList[1] = ~0x06; //'1'
digitList[2] = ~0x5b; //'2'
digitList[3] = ~0x4f; //'3'
gz_spi_write(digitList); // pass display bytes to SPI
sleep(4);
digitList[0] = ~0x00; //space
digitList[1] = ~0x00; //space
digitList[2] = ~0x00; //space
digitList[3] = ~0x00; //space
gz_spi_write(digitList); // pass display bytes to SPI
sleep(1);
gz_spi_close(); // close SPI channel
gz_clock_dis(); // turn off GPIO clock
return 0;
}
//.END
No comments:
Post a Comment