From bb58af2076c30e41d353ec193deddf54f6c3b8e8 Mon Sep 17 00:00:00 2001 From: Kevin Townsend Date: Sun, 26 Jun 2011 21:47:30 +0200 Subject: [PATCH] Added triangles + reset --- ChangeLog.txt | 12 +- Makefile | 14 ++- build/codelite/LPC1343 Workspace.tags | Bin 135168 -> 136192 bytes .../LPC1343 Workspace.workspace.session | 10 +- build/crossworks/LPC1343_CodeBase.hzp | 5 +- build/crossworks/LPC1343_CodeBase.hzs | 20 ++-- core/cpu/cpu.c | 21 ++++ core/cpu/cpu.h | 1 + drivers/lcd/tft/drawing.c | 107 ++++++++++++++++++ drivers/lcd/tft/drawing.h | 2 + project/cmd_tbl.h | 4 +- project/commands/cmd_uart.c | 2 +- projectconfig.h | 8 +- 13 files changed, 172 insertions(+), 34 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 3135a34..8338ec6 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,16 @@ -v0.9.2 - Ongoing +v0.9.3 - Ongoing ================ +- Add drawTriangle() and drawTriangleFilled() to + drawing.c +- Added cpuReset() to reset the board via AIRCR +- Removed text input dialogue from LCD CLI ('T') to + save a few KB. Command file still exists, just no + longer included in cmd_tbl.h by default. + +v0.9.2 - 14 June 2011 +===================== + - Added ISL12022M RTC Driver (/drivers/rtc/isl12022m) - Fixed a bug drawing filled circles with lcdDrawVLine - Added CLI command to toggle LCD backlight diff --git a/Makefile b/Makefile index 789305a..a211627 100644 --- a/Makefile +++ b/Makefile @@ -23,15 +23,15 @@ VPATH += project OBJS += commands.o VPATH += project/commands -OBJS += cmd_chibi_addr.o cmd_chibi_tx.o cmd_uart.o +OBJS += cmd_chibi_addr.o cmd_chibi_tx.o OBJS += cmd_i2ceeprom_read.o cmd_i2ceeprom_write.o cmd_lm75b_gettemp.o -OBJS += cmd_sysinfo.o cmd_sd_dir.o cmd_tswait.o cmd_orientation.o -OBJS += cmd_tsthreshhold.o cmd_backlight.o +OBJS += cmd_reset.o cmd_sd_dir.o cmd_sysinfo.o cmd_uart.o VPATH += project/commands/drawing -OBJS += cmd_button.o cmd_circle.o cmd_clear.o cmd_line.o cmd_pixel.o -OBJS += cmd_progress.o cmd_bmp.o cmd_gettext.o cmd_calibrate.o -OBJS += cmd_text.o cmd_textw.o cmd_rectangle.o +OBJS += cmd_backlight.o cmd_bmp.o cmd_button.o cmd_calibrate.o +OBJS += cmd_circle.o cmd_clear.o cmd_line.o cmd_orientation.o +OBJS += cmd_pixel.o cmd_progress.o cmd_rectangle.o cmd_text.o +OBJS += cmd_textw.o cmd_tsthreshhold.o cmd_tswait.o ########################################################################## # Optional driver files @@ -60,9 +60,11 @@ OBJS += drawing.o touchscreen.o bmp.o alphanumeric.o OBJS += dejavusans9.o dejavusansbold9.o dejavusanscondensed9.o OBJS += dejavusansmono8.o dejavusansmonobold8.o OBJS += veramono9.o veramonobold9.o veramono11.o veramonobold11.o + # LCD Driver (Only one can be included at a time!) OBJS += ILI9328.o # OBJS += ILI9325.o +# OBJS += ssd1331.o # OBJS += st7735.o # OBJS += st7783.o diff --git a/build/codelite/LPC1343 Workspace.tags b/build/codelite/LPC1343 Workspace.tags index ce7c0c64976208c99d2fd36dae1039cb0e224d8a..dfffc1d7cdd27bd0e27d4ee739b2e59a82344c91 100644 GIT binary patch delta 1315 zcmds1O-xi*6h1!><}uC;43%kznO7G=u!VqDl3F^09jKC0FpW)Z0=5VPhz2F5Ve7Ju#vu1Gr%{IKz51r9h42!liW+r7Z8-eqz&%Sn1qC^!x!DPXMR* zKL5fKmbYY-#l)I*J5+>|V(ok1gFNJ-rN7BM;-_)@YfanU^tm$*umO048|iO~lONCH zE=WUC8CQ&MUk;cJVx#9}G43}CVqHgKmC@#h`33KK74TvfIF?@|K5fm_njgAvill4G z(Yi)qn>6ud@lLJzZn|28^P|>ocLh3ju|mo;G1}FvklQE63N-y0C$s>6$8XUh4bxWq z9TQjzKS7HywOXx1GaF=N9-G7!zss?-zfTPKdt`VXThJ?SJivD_Pkd3eM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/LPC1343 Workspace.workspace.session b/build/codelite/LPC1343 Workspace.workspace.session index 9b71f5c..0a04b08 100644 --- a/build/codelite/LPC1343 Workspace.workspace.session +++ b/build/codelite/LPC1343 Workspace.workspace.session @@ -5,14 +5,14 @@ - - + + - - - + + + diff --git a/build/crossworks/LPC1343_CodeBase.hzp b/build/crossworks/LPC1343_CodeBase.hzp index 2f55d51..c2466de 100644 --- a/build/crossworks/LPC1343_CodeBase.hzp +++ b/build/crossworks/LPC1343_CodeBase.hzp @@ -1,7 +1,7 @@ - + @@ -339,6 +339,7 @@ + @@ -360,7 +361,7 @@ diff --git a/build/crossworks/LPC1343_CodeBase.hzs b/build/crossworks/LPC1343_CodeBase.hzs index 9eb6627..493c96b 100644 --- a/build/crossworks/LPC1343_CodeBase.hzs +++ b/build/crossworks/LPC1343_CodeBase.hzs @@ -19,13 +19,9 @@ - - - - - - + + @@ -45,10 +41,10 @@ - - - + + + @@ -60,8 +56,6 @@ - - - - + + diff --git a/core/cpu/cpu.c b/core/cpu/cpu.c index 03c6db6..4c674f2 100644 --- a/core/cpu/cpu.c +++ b/core/cpu/cpu.c @@ -167,3 +167,24 @@ void cpuInit (void) // Setup PLL (etc.) cpuPllSetup(CPU_MULTIPLIER_6); } + +/**************************************************************************/ +/*! + @brief Resets the device using the AIRCR register +*/ +/**************************************************************************/ +void cpuReset (void) +{ + // Reset device + SCB_AIRCR = SCB_AIRCR_VECTKEY_VALUE | SCB_AIRCR_SYSRESETREQ; // 0x05FA0004 + + // Ensure completion of memory access + // DSB acts as a special data synchronization memory barrier. Instructions + // that come after the DSB, in program order, do not execute until the DSB + // instruction completes. The DSB instruction completes when all explicit + // memory accesses before it complete. + __asm volatile("DSB"); + + // Wait for reset + while(1); +} diff --git a/core/cpu/cpu.h b/core/cpu/cpu.h index f2e12ac..6553fee 100644 --- a/core/cpu/cpu.h +++ b/core/cpu/cpu.h @@ -72,5 +72,6 @@ cpuMultiplier_t; void cpuPllSetup (cpuMultiplier_t multiplier); void cpuInit (void); +void cpuReset (void); #endif \ No newline at end of file diff --git a/drivers/lcd/tft/drawing.c b/drivers/lcd/tft/drawing.c index ed113a6..201df6c 100644 --- a/drivers/lcd/tft/drawing.c +++ b/drivers/lcd/tft/drawing.c @@ -890,6 +890,113 @@ void drawRectangleRounded ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, } } +/**************************************************************************/ +/*! + @brief Draws a triangle + + @param[in] x0 + x co-ordinate for point 0 + @param[in] y0 + y co-ordinate for point 0 + @param[in] x1 + x co-ordinate for point 1 + @param[in] y1 + y co-ordinate for point 1 + @param[in] x2 + x co-ordinate for point 2 + @param[in] y2 + y co-ordinate for point 2 + @param[in] color + Color used when drawing +*/ +/**************************************************************************/ +void drawTriangle ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) +{ + drawLine(x0, y0, x1, y1, color); + drawLine(x1, y1, x2, y2, color); + drawLine(x2, y2, x0, y0, color); +} + +/**************************************************************************/ +/*! + @brief Draws a triangle + + @param[in] x0 + x co-ordinate for point 0 + @param[in] y0 + y co-ordinate for point 0 + @param[in] x1 + x co-ordinate for point 1 + @param[in] y1 + y co-ordinate for point 1 + @param[in] x2 + x co-ordinate for point 2 + @param[in] y2 + y co-ordinate for point 2 + @param[in] color + Fill color + + @section Example + + @code + + // Draw a white triangle + drawTriangleFilled ( 100, 10, 20, 120, 230, 290, COLOR_WHITE); + // Draw black circles at each point of the triangle + drawCircleFilled(100, 10, 2, COLOR_BLACK); + drawCircleFilled(20, 120, 2, COLOR_BLACK); + drawCircleFilled(230, 290, 2, COLOR_BLACK); + + @endcode +*/ +/**************************************************************************/ +void drawTriangleFilled ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) +{ + // ToDo: re-order vertices by ascending Y values (smallest first) + + int32_t dx1, dx2, dx3; // Interpolation deltas + int32_t sx1, sx2, sy; // Scanline co-ordinates + + sx1=sx2=x0 * 1000; // Use fixed point math for x axis values + sy=y0; + + // Calculate interpolation deltas + if (y1-y0 > 0) dx1=((x1-x0)*1000)/(y1-y0); + else dx1=0; + if (y2-y0 > 0) dx2=((x2-x0)*1000)/(y2-y0); + else dx2=0; + if (y2-y1 > 0) dx3=((x2-x1)*1000)/(y2-y1); + else dx3=0; + + // Render scanlines (horizontal lines are the fastest rendering method) + if (dx1 > dx2) + { + for(; sy<=y1; sy++, sx1+=dx2, sx2+=dx1) + { + drawLine(sx1/1000, sy, sx2/1000, sy, color); + } + sx2 = x1*1000; + sy = y1; + for(; sy<=y2; sy++, sx1+=dx2, sx2+=dx3) + { + drawLine(sx1/1000, sy, sx2/1000, sy, color); + } + } + else + { + for(; sy<=y1; sy++, sx1+=dx1, sx2+=dx2) + { + drawLine(sx1/1000, sy, sx2/1000, sy, color); + } + sx1 = x1*1000; + sy = y1; + for(; sy<=y2; sy++, sx1+=dx3, sx2+=dx2) + { + drawLine(sx1/1000, sy, sx2/1000, sy, color); + } + } +} + /**************************************************************************/ /*! @brief Converts a 24-bit RGB color to an equivalent 16-bit RGB565 value diff --git a/drivers/lcd/tft/drawing.h b/drivers/lcd/tft/drawing.h index 127ab8a..7632392 100644 --- a/drivers/lcd/tft/drawing.h +++ b/drivers/lcd/tft/drawing.h @@ -87,6 +87,8 @@ void drawArrow ( uint16_t x, uint16_t y, uint16_t size, drawDire void drawRectangle ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color ); void drawRectangleFilled ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color ); void drawRectangleRounded ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color, uint16_t radius, drawRoundedCorners_t corners ); +void drawTriangle ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color); +void drawTriangleFilled ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color); void drawString ( uint16_t x, uint16_t y, uint16_t color, const FONT_INFO *fontInfo, char *str ); uint16_t drawGetStringWidth ( const FONT_INFO *fontInfo, char *str ); void drawProgressBar ( uint16_t x, uint16_t y, uint16_t width, uint16_t height, drawRoundedCorners_t borderCorners, drawRoundedCorners_t progressCorners, uint16_t borderColor, uint16_t borderFillColor, uint16_t progressBorderColor, uint16_t progressFillColor, uint8_t progress ); diff --git a/project/cmd_tbl.h b/project/cmd_tbl.h index a933817..7376c5a 100644 --- a/project/cmd_tbl.h +++ b/project/cmd_tbl.h @@ -48,6 +48,7 @@ // Function prototypes for the command table void cmd_help(uint8_t argc, char **argv); // handled by core/cmd/cmd.c void cmd_sysinfo(uint8_t argc, char **argv); +void cmd_reset(uint8_t argc, char **argv); #ifdef CFG_TFTLCD void cmd_backlight(uint8_t argc, char **argv); @@ -60,7 +61,6 @@ void cmd_rectangleround(uint8_t argc, char **argv); void cmd_pixel(uint8_t argc, char **argv); void cmd_progress(uint8_t argc, char **argv); void cmd_getpixel(uint8_t argc, char **argv); -void cmd_gettext(uint8_t argc, char **argv); void cmd_calibrate(uint8_t argc, char **argv); void cmd_orientation(uint8_t argc, char **argv); void cmd_text(uint8_t argc, char **argv); @@ -107,6 +107,7 @@ cmd_t cmd_tbl[] = // command name, min args, max args, hidden, function name, command description, syntax { "?", 0, 0, 0, cmd_help , "Help" , CMD_NOPARAMS }, { "V", 0, 0, 0, cmd_sysinfo , "System Info" , CMD_NOPARAMS }, + { "Z", 0, 0, 0, cmd_reset , "Reset" , CMD_NOPARAMS }, #ifdef CFG_I2CEEPROM { "e", 1, 1, 0, cmd_i2ceeprom_read , "EEPROM Read" , "'e '" }, @@ -132,7 +133,6 @@ cmd_t cmd_tbl[] = { "R", 7, 7, 0, cmd_rectangleround , "Rounded Rectangle" , "'R '" }, { "s", 2, 99, 0, cmd_textw , "Text Width" , "'s '" }, { "t", 5, 99, 0, cmd_text , "Text" , "'t '" }, - { "T", 0, 0, 0, cmd_gettext , "Text Dialogue" , CMD_NOPARAMS }, { "W", 0, 1, 0, cmd_tswait , "Wait for Touch" , "'W []'" }, { "x", 0, 1, 0, cmd_tsthreshhold , "Touch Threshold" , "'x [<0..254>]'" }, #endif diff --git a/project/commands/cmd_uart.c b/project/commands/cmd_uart.c index 74ad470..91081f7 100644 --- a/project/commands/cmd_uart.c +++ b/project/commands/cmd_uart.c @@ -88,7 +88,7 @@ void cmd_uart(uint8_t argc, char **argv) } else { - printf("%u%s", uartEEPROM, CFG_PRINTF_NEWLINE); + printf("%u%s", (unsigned int)uartEEPROM, CFG_PRINTF_NEWLINE); } #endif } diff --git a/projectconfig.h b/projectconfig.h index 28269c8..c90a88a 100644 --- a/projectconfig.h +++ b/projectconfig.h @@ -48,8 +48,8 @@ are using by enabling one of the following definitions. The code base will then try to configure itself accordingly for that board. -----------------------------------------------------------------------*/ - #define CFG_BRD_LPC1343_REFDESIGN - // #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB + // #define CFG_BRD_LPC1343_REFDESIGN + #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB // #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART // #define CFG_BRD_LPC1343_802154USBSTICK /*=========================================================================*/ @@ -129,7 +129,7 @@ -----------------------------------------------------------------------*/ #define CFG_FIRMWARE_VERSION_MAJOR (0) #define CFG_FIRMWARE_VERSION_MINOR (9) - #define CFG_FIRMWARE_VERSION_REVISION (2) + #define CFG_FIRMWARE_VERSION_REVISION (3) /*=========================================================================*/ @@ -343,7 +343,7 @@ #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART // #define CFG_USBHID // #define CFG_USBCDC - #define CFG_USBCDC_BAUDRATE (115200) + #define CFG_USBCDC_BAUDRATE (57600) #define CFG_USBCDC_INITTIMEOUT (5000) #define CFG_USBCDC_BUFFERSIZE (256) #endif -- 2.20.1