Merge pull request #29 from Tectu/master

Merge Tectu Changes
This commit is contained in:
Andrew Hannam 2013-05-15 08:37:00 -07:00
commit 9ad0d07923
5 changed files with 342 additions and 326 deletions

View file

@ -30,7 +30,7 @@
#include "gfx.h" #include "gfx.h"
int main(void) { int main(void) {
char charmap[8]; uint8_t charmap[8];
halInit(); halInit();
chSysInit(); chSysInit();

View file

@ -112,7 +112,7 @@ bool_t tdisp_lld_init(void) {
// write_cmd(0x38); // write_cmd(0x38);
// chThdSleepMilliseconds(64); // chThdSleepMilliseconds(64);
// //
// displaycontrol = DISPLAY_ON | CURSOR_ON | CURSOR_BLINK; // The default displaycontrol // displaycontrol = TDISP_DISPLAY_ON | TDISP_CURSOR_ON | TDISP_CURSOR_BLINK; // The default displaycontrol
// write_cmd(0x08 | displaycontrol); // write_cmd(0x08 | displaycontrol);
// chThdSleepMicroseconds(50); // chThdSleepMicroseconds(50);
// //
@ -171,26 +171,26 @@ void tdisp_lld_control(uint16_t what, uint16_t value) {
switch(what) { switch(what) {
case TDISP_CTRL_BACKLIGHT: case TDISP_CTRL_BACKLIGHT:
if ((uint8_t)value) if ((uint8_t)value)
displaycontrol |= DISPLAY_ON; displaycontrol |= TDISP_DISPLAY_ON;
else else
displaycontrol &= ~DISPLAY_ON; displaycontrol &= ~TDISP_DISPLAY_ON;
write_cmd(0x08 | displaycontrol); write_cmd(0x08 | displaycontrol);
break; break;
case TDISP_CTRL_CURSOR: case TDISP_CTRL_CURSOR:
switch((uint8_t)value) { switch((uint8_t)value) {
case cursorOff: case cursorOff:
displaycontrol &= ~CURSOR_ON; displaycontrol &= ~TDISP_CURSOR_ON;
break; break;
case cursorBlock: case cursorBlock:
case cursorUnderline: case cursorUnderline:
case cursorBar: case cursorBar:
displaycontrol = (displaycontrol | CURSOR_ON) & ~CURSOR_BLINK; displaycontrol = (displaycontrol | TDISP_CURSOR_ON) & ~TDISP_CURSOR_BLINK;
break; break;
case cursorBlinkingBlock: case cursorBlinkingBlock:
case cursorBlinkingUnderline: case cursorBlinkingUnderline:
case cursorBlinkingBar: case cursorBlinkingBar:
default: default:
displaycontrol |= (CURSOR_ON | CURSOR_BLINK); displaycontrol |= (TDISP_CURSOR_ON | TDISP_CURSOR_BLINK);
break; break;
} }
write_cmd(0x08 | displaycontrol); write_cmd(0x08 | displaycontrol);

View file

@ -108,7 +108,7 @@ void tdispSetCursor(coord_t col, coord_t row);
* made up of @p tdispGetCharBitWidth() bits of data. Note that bits in multiple rows are not * made up of @p tdispGetCharBitWidth() bits of data. Note that bits in multiple rows are not
* packed. * packed.
*/ */
void tdispCreateChar(uint8_t address, uint8_t *charmap); void tdispCreateChar(uint8_t address, char* charmap);
/** /**
* @brief Draws a single character at the current cursor position and advances the cursor * @brief Draws a single character at the current cursor position and advances the cursor
@ -127,7 +127,18 @@ void tdispDrawChar(char c);
* @note Any characters written past the end of a row may or may not be displayed on * @note Any characters written past the end of a row may or may not be displayed on
* the next row. The cursor is also left in an undefined position. * the next row. The cursor is also left in an undefined position.
*/ */
void tdispDrawString(char *s); void tdispDrawString(char* s);
/**
* @brief Draws a string at a specific position
*
* @param[in] col The column (x)
* @param[in] row The row (y)
* @param[in] s The string to be drawin
*
* @note The cursor position after this call is not the same as before.
*/
void tdispDrawStringLocation(coord_t col, coord_t row, char* s);
/** /**
* @brief Control different display properties * @brief Control different display properties
@ -138,14 +149,14 @@ void tdispDrawString(char *s);
* @param[in] what What you want to control * @param[in] what What you want to control
* @param[in] value The value to be assigned * @param[in] value The value to be assigned
*/ */
void tdispControl(uint16_t what, void *value); void tdispControl(uint16_t what, void* value);
/** /**
* @brief Set the backlight level * @brief Set the backlight level
* *
* @param[in] percent A percentage from 0 to 100%. 0% will turn off the display * @param[in] percent A percentage from 0 to 100%. 0% will turn off the display
*/ */
#define tdispSetBacklight(percent) tdispControl(TDISP_CTRL_BACKLIGHT, (void *)((uint8_t)(percent))) #define tdispSetBacklight(percent) tdispControl(TDISP_CTRL_BACKLIGHT, (void*)((uint8_t)(percent)))
/** /**
* @brief Set the cursor shape * @brief Set the cursor shape
@ -155,7 +166,7 @@ void tdispControl(uint16_t what, void *value);
* @note Not all shapes are necessarily supported. The driver will make a similar * @note Not all shapes are necessarily supported. The driver will make a similar
* choice if the one specified is not available. * choice if the one specified is not available.
*/ */
#define tdispSetCursorShape(shape) tdispControl(TDISP_CTRL_CURSOR, (void *)((cursorshape)(shape))) #define tdispSetCursorShape(shape) tdispControl(TDISP_CTRL_CURSOR, (void*)((cursorshape)(shape)))
/** /**
* @brief Get the number of columns (width) in the display * @brief Get the number of columns (width) in the display

View file

@ -94,6 +94,11 @@ void tdispDrawString(char *s) {
MUTEX_LEAVE(); MUTEX_LEAVE();
} }
void tdispDrawStringLocation(coord_t col, coord_t row, char *s) {
tdispSetCursor(col, row);
tdispDrawString(s);
}
void tdispControl(uint16_t what, void *value) { void tdispControl(uint16_t what, void *value) {
MUTEX_ENTER(); MUTEX_ENTER();
tdisp_lld_control(what, value); tdisp_lld_control(what, value);