- *** Renamed '/drivers/spiflash' to '/drivers/storage/spiflash' ***
- *** Renamed '/drivers/eeprom' to '/drivers/storage/eeprom' ***
- *** Renamed '/drivers/lcd' to '/drivers/display' ***
+- Removed height parameter from drawButton. It's now
+ calculated based on the font height, and centered.
+- Added bell to CLI when backspace is pressed beyond
+ the starting position (cosmetic, but still useful)
+- Removed dependency on /core/libc files in Crossworks
+ when redirecting printf (added printf replacement
+ to sysinit.c)
- Added basic AS1115 driver for segment displays
- Added driver for HX8340-B based LCDs
- Added flag to projectconfig.h to disable the default
VPATH += core core/adc core/cmd core/cpu core/gpio core/i2c core/pmu
VPATH += core/ssp core/systick core/timer16 core/timer32 core/uart
-VPATH += core/usbhid-rom core/libc core/wdt core/usbcdc core/pwm
-VPATH += core/iap
+VPATH += core/usbhid-rom core/wdt core/usbcdc core/pwm core/iap
+VPATH += core/libc
+OBJS += stdio.o string.o
OBJS += adc.o cpu.o cmd.o gpio.o i2c.o pmu.o ssp.o systick.o timer16.o
-OBJS += timer32.o uart.o uart_buf.o usbconfig.o usbhid.o stdio.o string.o
+OBJS += timer32.o uart.o uart_buf.o usbconfig.o usbhid.o
OBJS += wdt.o cdcuser.o cdc_buf.o usbcore.o usbdesc.o usbhw.o usbuser.o
OBJS += sysinit.o pwm.o iap.o
#if CFG_INTERFACE_SILENTMODE == 0
printf("%c",c);
#endif
- if (msg_ptr > msg)
+ if (msg_ptr == msg)
+ {
+ // Send bell alert and space (to maintain position)
+ printf("\a ");
+ }
+ else if (msg_ptr > msg)
{
msg_ptr--;
}
+++ /dev/null
-/*
- * This file is part of the libpayload project.
- *
- * Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-int isalpha(int c)
-{
- return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
-}
-
-int isascii(int c)
-{
- return (c >= 0 && c <= 127);
-}
-
-int isblank(int c)
-{
- return (c == ' ' || c == '\t');
-}
-
-int iscntrl(int c)
-{
- return (c <= 31 || c == 127);
-}
-
-int isdigit(int c)
-{
- return (c >= '0' && c <= '9');
-}
-
-int isalnum(int c)
-{
- return isalpha(c) || isdigit(c);
-}
-
-int isgraph(int c)
-{
- return (c >= 33 && c <= 126);
-}
-
-int islower(int c)
-{
- return (c >= 'a' && c <= 'z');
-}
-
-int isprint(int c)
-{
- return (c >= 32 && c <= 126);
-}
-
-
-int isspace(int c)
-{
- return (c == ' ' || (c >= '\t' || c <= '\r'));
-}
-
-int isupper(int c)
-{
- return (c >= 'A' && c <= 'Z');
-}
-
-int tolower(int c)
-{
- return (c >= 'A' && c <= 'Z') ? (c + 32) : c;
-}
-
-int toupper(int c)
-{
- return (c >= 'a' && c <= 'z') ? (c - 32) : c;
-}
-
-int isxdigit(int c)
-{
- return isdigit(c) || (tolower(c) >= 'a' && tolower(c) <= 'z');
-}
-
-int ispunct(int c)
-{
- return isprint(c) && !isspace(c) && !isalnum(c);
-}
#include <stdarg.h>
#include <stdint.h>
-//------------------------------------------------------------------------------
-// Local Definitions
-//------------------------------------------------------------------------------
-
-// Maximum string size allowed (in bytes).
-#define MAX_STRING_SIZE 255
+#include "projectconfig.h" // For CFG_PRINTF_MAXSTRINGSIZE
//------------------------------------------------------------------------------
// Global Variables
//------------------------------------------------------------------------------
signed int vsprintf(char *pString, const char *pFormat, va_list ap)
{
- return vsnprintf(pString, MAX_STRING_SIZE, pFormat, ap);
+ return vsnprintf(pString, CFG_PRINTF_MAXSTRINGSIZE, pFormat, ap);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
signed int vprintf(const char *pFormat, va_list ap)
{
- char pStr[MAX_STRING_SIZE];
- char pError[] = "stdio.c: increase MAX_STRING_SIZE\r\n";
+ char pStr[CFG_PRINTF_MAXSTRINGSIZE];
+ char pError[] = "stdio.c: increase CFG_PRINTF_MAXSTRINGSIZE\r\n";
// Write formatted string in buffer
- if (vsprintf(pStr, pFormat, ap) >= MAX_STRING_SIZE) {
+ if (vsprintf(pStr, pFormat, ap) >= CFG_PRINTF_MAXSTRINGSIZE) {
puts(pError);
- while (1); // Increase MAX_STRING_SIZE
+ while (1); // Increase CFG_PRINTF_MAXSTRINGSIZE
}
// Display string
{
case '<':
// Backspace
- drawButton (alphaBtnX[col], alphaBtnY[row], ALPHA_BTN_WIDTH, ALPHA_BTN_HEIGHT, &dejaVuSans9ptFontInfo, 7, border, fill, font, NULL);
+ drawButton (alphaBtnX[col], alphaBtnY[row], ALPHA_BTN_WIDTH, &dejaVuSans9ptFontInfo, 7, border, fill, font, NULL);
drawArrow (alphaBtnX[col] + ALPHA_BTN_WIDTH / 2 - 3, alphaBtnY[row] + ALPHA_BTN_HEIGHT / 2, 7, DRAW_DIRECTION_LEFT, font);
break;
case '*':
// Page Shift
- drawButton (alphaBtnX[col], alphaBtnY[row], ALPHA_BTN_WIDTH, ALPHA_BTN_HEIGHT, &dejaVuSans9ptFontInfo, 7, border, fill, font, NULL);
+ drawButton (alphaBtnX[col], alphaBtnY[row], ALPHA_BTN_WIDTH, &dejaVuSans9ptFontInfo, 7, border, fill, font, NULL);
drawArrow (alphaBtnX[col] + ALPHA_BTN_WIDTH / 2, (alphaBtnY[row] + ALPHA_BTN_HEIGHT / 2) - 3, 7, DRAW_DIRECTION_UP, font);
break;
case '>':
// OK
- drawButton (alphaBtnX[col], alphaBtnY[row], ALPHA_BTN_WIDTH, ALPHA_BTN_HEIGHT, &dejaVuSans9ptFontInfo, 7, border, fill, font, "OK");
+ drawButton (alphaBtnX[col], alphaBtnY[row], ALPHA_BTN_WIDTH, &dejaVuSans9ptFontInfo, 7, border, fill, font, "OK");
break;
default:
// Standard character
- drawButton (alphaBtnX[col], alphaBtnY[row], ALPHA_BTN_WIDTH, ALPHA_BTN_HEIGHT, &dejaVuSans9ptFontInfo, 7, border, fill, font, key);
+ drawButton (alphaBtnX[col], alphaBtnY[row], ALPHA_BTN_WIDTH, &dejaVuSans9ptFontInfo, 7, border, fill, font, key);
break;
}
}
Total height of the button in pixels
@param[in] fontInfo
Pointer to the FONT_INFO used to render the button text
- @param[in] fontHeight
- The height in pixels of the font (used for centering)
@param[in] borderclr
The rgb565 border color
@param[in] fillclr
#include "drivers/displays/tft/fonts/dejavusans9.h"
// Draw two buttons using Vera Sans Bold 9
- drawButton(20, 195, 200, 35, &dejaVuSans9ptFontInfo, 7, COLOR_GRAY_80, COLOR_GRAY_80, COLOR_WHITE, "System Settings");
- drawButton(20, 235, 200, 35, &dejaVuSans9ptFontInfo, 7, COLOR_THEME_LIMEGREEN_DARKER, COLOR_THEME_LIMEGREEN_BASE, COLOR_BLACK, "System Settings");
+ drawButton(20, 195, 200, 35, &dejaVuSans9ptFontInfo, COLOR_GRAY_80, COLOR_GRAY_80, COLOR_WHITE, "System Settings");
+ drawButton(20, 235, 200, 35, &dejaVuSans9ptFontInfo, COLOR_THEME_LIMEGREEN_DARKER, COLOR_THEME_LIMEGREEN_BASE, COLOR_BLACK, "System Settings");
@endcode
*/
/**************************************************************************/
-void drawButton(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const FONT_INFO *fontInfo, uint16_t fontHeight, uint16_t borderclr, uint16_t fillclr, uint16_t fontclr, char* text)
+void drawButton(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const FONT_INFO *fontInfo, uint16_t borderclr, uint16_t fillclr, uint16_t fontclr, char* text)
{
// Border
drawRectangleRounded(x, y, x + width, y + height, borderclr, 5, DRAW_ROUNDEDCORNERS_ALL);
{
uint16_t textWidth = drawGetStringWidth(&*fontInfo, text);
uint16_t xStart = x + (width / 2) - (textWidth / 2);
- uint16_t yStart = y + (height / 2) - (fontHeight / 2) + 1;
+ uint16_t yStart = y + (height / 2) - (fontInfo->height / 2) + 1;
drawString(xStart, yStart, fontclr, &*fontInfo, text);
}
}
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 );
-void drawButton ( uint16_t x, uint16_t y, uint16_t width, uint16_t height, const FONT_INFO *fontInfo, uint16_t fontHeight, uint16_t borderclr, uint16_t fillclr, uint16_t fontclr, char* text );
+void drawButton ( uint16_t x, uint16_t y, uint16_t width, uint16_t height, const FONT_INFO *fontInfo, uint16_t borderclr, uint16_t fillclr, uint16_t fontclr, char* text );
void drawIcon16 ( uint16_t x, uint16_t y, uint16_t color, uint16_t icon[] );
uint16_t drawRGB24toRGB565 ( uint8_t r, uint8_t g, uint8_t b );
uint32_t drawRGB565toBGRA32 ( uint16_t color );
// DATA(0xBF);
// Clear screen
- lcdFillRGB(COLOR_RED);
+ lcdFillRGB(COLOR_BLACK);
// Turn the display on
CMD(SSD1351_CMD_SLEEPMODE_DISPLAYON);
if (argc == 7)
{
// Render the button with no text
- drawButton(x, y, w, h, &dejaVuSans9ptFontInfo, 7, (uint16_t)border, (uint16_t)fill, (uint16_t)font, NULL);
+ drawButton(x, y, w, h, &dejaVuSans9ptFontInfo, (uint16_t)border, (uint16_t)fill, (uint16_t)font, NULL);
}
else
{
*data_ptr++ = '\0';
// Render the button with text
- drawButton(x, y, w, h, &dejaVuSans9ptFontInfo, 7, (uint16_t)border, (uint16_t)fill, (uint16_t)font, (char *)&data);
+ drawButton(x, y, w, h, &dejaVuSans9ptFontInfo, (uint16_t)border, (uint16_t)fill, (uint16_t)font, (char *)&data);
}
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdarg.h>
#include "sysinit.h"
return 0;
}
+
+// Override printf here if we're using Crossworks for ARM
+// so that we can still use the custom libc libraries.
+// For Codelite and compiling from the makefile (Yagarto, etc.)
+// this is done in /core/libc
+
+#ifdef __CROSSWORKS_ARM
+
+/**************************************************************************/
+/*!
+ @brief Outputs a formatted string on the DBGU stream. Format arguments
+ are given in a va_list instance.
+
+ @param[in] pFormat
+ Format string
+ @param[in] ap
+ Argument list
+*/
+/**************************************************************************/
+signed int vprintf(const char *pFormat, va_list ap)
+{
+ char pStr[CFG_PRINTF_MAXSTRINGSIZE];
+ char pError[] = "stdio.c: increase CFG_PRINTF_MAXSTRINGSIZE\r\n";
+
+ // Write formatted string in buffer
+ if (vsprintf(pStr, pFormat, ap) >= CFG_PRINTF_MAXSTRINGSIZE) {
+
+ puts(pError);
+ while (1); // Increase CFG_PRINTF_MAXSTRINGSIZE
+ }
+
+ // Display string
+ return puts(pStr);
+}
+
+/**************************************************************************/
+/*!
+ @brief Outputs a formatted string on the DBGU stream, using a
+ variable number of arguments
+
+ @param[in] pFormat
+ Format string
+*/
+/**************************************************************************/
+signed int printf(const char *pFormat, ...)
+{
+ va_list ap;
+ signed int result;
+
+ // Forward call to vprintf
+ va_start(ap, pFormat);
+ result = vprintf(pFormat, ap);
+ va_end(ap);
+
+ return result;
+}
+
+#endif
\ No newline at end of file