X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=test-display%2Fmain.c;h=8fd56363b7125ca5b9f14518bc73ccd65b842b86;hb=bb37203461a4380e32be26594a74b77727dda97d;hp=0573a5e7c42f9c884c1d8a98613ea1bba195a4d1;hpb=81f712dc85d4928294b7f506777080a8b37902c1;p=home-hw.git diff --git a/test-display/main.c b/test-display/main.c index 0573a5e..8fd5636 100644 --- a/test-display/main.c +++ b/test-display/main.c @@ -97,13 +97,13 @@ static void delay_ms(uint ms) /* * Display digits: * - * ---- 20 ---- + * ---- 40 ---- * | | * | | - * 40 10 + * 20 80 * | | * | | - * ---- 80 ---- + * ---- 10 ---- * | | * | | * 08 02 @@ -114,21 +114,23 @@ static void delay_ms(uint ms) */ static byte disp[4]; -static byte ctrl = 0x77; +static byte ctrl = 0x56; static void display_update(void) { - byte cmds[6]; + debug_puts("Display pdate\n"); + byte cmds[4]; cmds[0] = 0; cmds[1] = ctrl; - cmds[2] = (disp[0] & 0xf0) | (disp[2] >> 4); - cmds[3] = (disp[1] & 0xf0) | (disp[3] >> 4); - cmds[4] = (disp[2] & 0x0f) | (disp[0] << 4); - cmds[5] = (disp[3] & 0x0f) | (disp[1] << 4); + cmds[2] = ((disp[1] & 0x88) >> 3) | ((disp[1] & 0x44) >> 1) | ((disp[1] & 0x22) << 1) | ((disp[1] & 0x11) << 3); + cmds[3] = disp[0]; + i2c_transfer7(I2C1, 0x76/2, (byte *) cmds, sizeof(cmds), NULL, 0); - debug_puts("I2C transfer\n"); + cmds[2] = ((disp[3] & 0x88) >> 3) | ((disp[3] & 0x44) >> 1) | ((disp[3] & 0x22) << 1) | ((disp[3] & 0x11) << 3); + cmds[3] = disp[2]; i2c_transfer7(I2C1, 0x70/2, (byte *) cmds, sizeof(cmds), NULL, 0); - debug_puts("I2C done\n"); + + debug_puts("Update done\n"); } static void display_init(void) @@ -138,10 +140,10 @@ static void display_init(void) i2c_set_speed(I2C1, i2c_speed_sm_100k, rcc_apb1_frequency / 1000000); i2c_peripheral_enable(I2C1); - disp[0] = 0x7f; - disp[1] = 0x12; - disp[2] = 0xbc; - disp[3] = 0xb6; + disp[0] = 0x82; + disp[1] = 0xdc; + disp[2] = 0xd6; + disp[3] = 0xb2; display_update(); } @@ -171,22 +173,22 @@ static void display_test(void) } static const byte lcd_font[] = { - [0] = 0x7e, - [1] = 0x12, - [2] = 0xbc, - [3] = 0xb6, - [4] = 0xd2, - [5] = 0xe6, - [6] = 0xee, - [7] = 0x32, + [0] = 0xee, + [1] = 0x82, + [2] = 0xdc, + [3] = 0xd6, + [4] = 0xb2, + [5] = 0x76, + [6] = 0x7e, + [7] = 0xc2, [8] = 0xfe, [9] = 0xf6, - [10] = 0xfa, - [11] = 0xce, + [10] = 0xea, + [11] = 0x3e, [12] = 0x6c, [13] = 0x9e, - [14] = 0xec, - [15] = 0xe8, + [14] = 0x7c, + [15] = 0x78, }; /*** USB ***/