Mercurial > ~darius > hgwebdir.cgi > stm32test
changeset 12:093bc0c3b1cc
Add delay, ellipse and line demos.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Mon, 06 Feb 2012 23:55:53 +1030 |
parents | ca48036c82ef |
children | 96c345d304af |
files | main.c |
diffstat | 1 files changed, 44 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/main.c Mon Feb 06 23:55:11 2012 +1030 +++ b/main.c Mon Feb 06 23:55:53 2012 +1030 @@ -106,7 +106,10 @@ char buf[40]; struct tm nowtm; time_t now; - + uint16_t x, y, x1, y1, z1, z2, r, c, rx, ry; + float t, t2; + char col; + cmd.state = cmd.len = 0; /* Init hardware - configure IO ports and external peripherals */ @@ -129,6 +132,21 @@ /* Say hello */ fputs("\r\n\r\n\r\nHello world\r\n", stdout); + lcd_stripes(); + + lcd_circle(20, 20, 20, 1, LCD_RED); /* Bottom left */ + lcd_circle(300, 220, 20, 1, LCD_WHITE); /* Top right */ + lcd_circle(20, 220, 20, 1, LCD_BLUE); /* Top left */ + lcd_circle(300, 20, 20, 1, LCD_GREEN); /* Bottom right */ + + lcd_line(20, 20, 20, 220, LCD_BLACK); + lcd_line(20, 220, 300, 220, LCD_BLACK); + lcd_line(300, 220, 300, 20, LCD_BLACK); + lcd_line(300, 20, 20, 20, LCD_BLACK); + + lcd_ellipse(160, 120, 50, 30, 1, LCD_WHITE); + lcd_ellipse(160, 120, 30, 50, 1, LCD_WHITE); + while (1) { fputs("> ", stdout); @@ -149,8 +167,6 @@ } else if (!strncmp("read", cmd.buf, 4)) { printf("PB5 = %d\r\n", GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_15)); } else if (!strncmp("touch", cmd.buf, 5)) { - uint16_t x, y, z1, z2; - float t, t2; for (int i = 0; i < 10; i++) { tp_getcoords(&x, &y, &z1, &z2, &t, &t2); printf("X = %5d Y = %5d Z1 = %5d Z2 = %5d T = %7.2f T2 = %7.2f\r\n", x, y, z1, z2, t, t2); @@ -197,26 +213,36 @@ delay(10000); fputs("Done\r\n", stdout); } else if (!strncmp("circ ", cmd.buf, 5)) { - uint16_t x, y, r, c; - char col; - if (sscanf(cmd.buf, "circ %hu %hu %hu %c", &x, &y, &r, &col) != 4) { printf("Unable to parse circ args\r\n"); goto out; } - col = toupper(col); - if (col == 'R') - c = LCD_RED; - else if (col == 'G') - c = LCD_GREEN; - else if (col == 'B') - c = LCD_BLUE; - else if (col == 'L') - c = LCD_BLACK; - else - c = LCD_WHITE; - lcd_circle(x, y, r, c); + c = lcd_parsecol(col); + lcd_circle(x, y, r, 0, c); + } else if (!strncmp("ellip ", cmd.buf, 6)) { + if (sscanf(cmd.buf, "ellip %hu %hu %hu %hu %c", &x, &y, &rx, &ry, &col) != 5) { + printf("Unable to parse circ args\r\n"); + goto out; + } + + c = lcd_parsecol(col); + lcd_ellipse(x, y, rx, ry, 0, c); + } else if (!strncmp("line ", cmd.buf, 5)) { + if (sscanf(cmd.buf, "line %hu %hu %hu %hu %c", &x, &y, &x1, &y1, &col) != 5) { + printf("Unable to parse line args\r\n"); + goto out; + } + + c = lcd_parsecol(col); + lcd_line(x, y, x1, y1, c); + } else if (!strncmp("delay", cmd.buf, 5)) { + for (x = 0; x < 100; x++) { + GPIO_SetBits(GPIOE, GPIO_Pin_3); + _usleep16(30000); + GPIO_ResetBits(GPIOE, GPIO_Pin_3); + _usleep16(60000); + } } else if (!strncmp("zz", cmd.buf, 2)) { NVIC_SystemReset(); } else {