|
Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
|
#include <math.h>#include <stdarg.h>#include <stdbool.h>#include <stdint.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include "cascoda-bm/cascoda_evbme.h"#include "cascoda-bm/cascoda_interface.h"#include "cascoda-util/cascoda_tasklet.h"#include "gfx_driver.h"#include "gfx_library.h"
Macros | |
| #define | min(a, b) (((a) < (b)) ? (a) : (b)) |
| #define | _swap_int16_t(a, b) |
Functions | |
| void | display_drawCircleHelper (uint16_t x0, uint16_t y0, uint16_t r, uint8_t cornername, uint16_t color) |
| Quarter-circle drawer, used to do circles and roundrects. More... | |
| void | display_fillCircleHelper (uint16_t x0, uint16_t y0, uint16_t r, uint8_t corners, uint16_t delta, uint16_t color) |
| Quarter-circle drawer with fill, used for circles and roundrects. More... | |
| void | writeLine (uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) |
| Write a line. More... | |
| uint8_t | printNumber (uint32_t n, int8_t n_width, uint8_t _flags) |
| void | printFloat (float float_n, int8_t f_width, int8_t decimal, uint8_t _flags) |
| void | v_printf (const char *fmt, va_list arp) |
| void | fillRect (uint16_t x0, uint16_t y0, uint16_t x1, int16_t y1, uint16_t color) |
| void | display_drawPixel (int16_t x, int16_t y, uint16_t color) |
| void | display_clear (void) |
| clears the frame buffer intializes the background on white. More... | |
| void | display_setRotation (uint16_t rotation) |
| set the rotation prints starting at the cursor position. More... | |
| void | display_fillRect (uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color) |
| draw filled rectangle More... | |
| void | display_drawHLine (uint16_t x0, uint16_t y0, uint16_t x1, uint16_t color) |
| void | display_drawVLine (uint16_t x0, uint16_t y0, uint16_t y1, uint16_t color) |
| void | display_drawLine (uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) |
| Draw a line. More... | |
| void | display_drawCircle (uint16_t x0, uint16_t y0, uint16_t r, uint16_t color) |
| Draw a circle outline. More... | |
| void | display_fillCircle (uint16_t x0, uint16_t y0, uint16_t r, uint16_t color) |
| Draw a circle with filled color. More... | |
| void | display_drawRect (uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t color) |
| Draw a rectangle with no fill color. More... | |
| void | display_drawRoundRect (uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t r, uint16_t color) |
| Draw a rounded rectangle with no fill color. More... | |
| void | display_fillRoundRect (uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t r, uint16_t color) |
| Draw a rounded rectangle with fill color. More... | |
| void | display_drawTriangle (uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) |
| Draw a triangle with no fill color. More... | |
| void | display_fillTriangle (uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) |
| Draw a triangle with color-fill. More... | |
| void | display_putc (uint8_t c) |
| Print one byte/character of data. More... | |
| void | display_puts (const uint8_t *s) |
| Print a string to the display. More... | |
| void | display_puts_max_n (const uint8_t *s, uint8_t n) |
| Print a maximum of (n - 1) characters from the input string to the display and put "..." as the nth character afterwards to indicate that the string was truncated. More... | |
| void | display_customChar (const uint8_t *c) |
| void | display_drawChar (uint16_t x, uint16_t y, uint8_t c, uint16_t color, uint16_t bg, uint8_t size) |
| Draw a single character. More... | |
| void | display_setCursor (uint16_t x, uint16_t y) |
| Set text cursor location. More... | |
| uint16_t | display_getCursorX (void) |
| Get text cursor X location. More... | |
| uint16_t | display_getCursorY (void) |
| Get text cursor Y location. More... | |
| void | display_setTextSize (uint8_t s) |
| Set text 'magnification' size. More... | |
| void | display_setTextColor (uint16_t c, uint16_t b) |
| Set text font color with custom background color. More... | |
| void | display_setTextWrap (bool w) |
| Whether text that is too long should 'wrap' around to the next line. More... | |
| uint8_t | display_getRotation (void) |
| Get rotation setting for display. More... | |
| uint16_t | display_getWidth (void) |
| Get width of the display, accounting for the current rotation. More... | |
| uint16_t | display_getHeight (void) |
| Get height of the display, accounting for the current rotation. More... | |
| uint16_t | display_color565 (uint8_t red, uint8_t green, uint8_t blue) |
| Given 8-bit red, green and blue values, return a 'packed' 16-bit color value in '565' RGB format (5 bits red, 6 bits green, 5 bits blue). More... | |
| void | display_drawBitmapV1 (uint16_t x, uint16_t y, const uint8_t *bitmap, uint16_t w, uint16_t h, uint16_t color) |
| Draw a ROM-resident 1-bit image at the specified (x,y) position, using the specified foreground color (unset bits are transparent). More... | |
| void | display_drawBitmapV1_bg (uint16_t x, uint16_t y, const uint8_t *bitmap, uint16_t w, uint16_t h, uint16_t color, uint16_t bg) |
| Draw a ROM-resident 1-bit image at the specified (x,y) position, using the specified foreground (for set bits) and background (unset bits) colors. More... | |
| void | display_drawBitmapV2 (uint16_t x, uint16_t y, const uint8_t *bitmap, uint16_t w, uint16_t h, uint16_t color) |
| Draw a ROM-resident 1-bit image at the specified (x,y) position, using the specified foreground color (unset bits are transparent). More... | |
| void | display_drawBitmapV2_bg (uint16_t x, uint16_t y, const uint8_t *bitmap, uint16_t w, uint16_t h, uint16_t color, uint16_t bg) |
| Draw a ROM-resident 1-bit image at the specified (x,y) position, using the specified foreground (for set bits) and background (unset bits) colors. More... | |
| void | display_double (char *text, int text_size, double v, int decimalDigits) |
| convert a float to a string More... | |
| void | display_slider (int x, int y, int length, int value) |
| void | display_progressbar (int x, int y, int length, int value) |
| #define _swap_int16_t | ( | a, | |
| b | |||
| ) |
| #define min | ( | a, | |
| b | |||
| ) | (((a) < (b)) ? (a) : (b)) |
| void display_clear | ( | void | ) |
clears the frame buffer intializes the background on white.
| uint16_t display_color565 | ( | uint8_t | red, |
| uint8_t | green, | ||
| uint8_t | blue | ||
| ) |
Given 8-bit red, green and blue values, return a 'packed' 16-bit color value in '565' RGB format (5 bits red, 6 bits green, 5 bits blue).
This is just a mathematical operation, no hardware is touched.
| red | 8-bit red brightnesss (0 = off, 255 = max). |
| green | 8-bit green brightnesss (0 = off, 255 = max). |
| blue | 8-bit blue brightnesss (0 = off, 255 = max). |
| void display_customChar | ( | const uint8_t * | c | ) |
| void display_double | ( | char * | text, |
| int | text_size, | ||
| double | v, | ||
| int | decimalDigits | ||
| ) |
convert a float to a string
| text | the text buffer to write in |
| text_size | the size of the text buffer |
| v | the floating number to display |
| decimalDigits | the decimal digit to display |
| void display_drawBitmapV1 | ( | uint16_t | x, |
| uint16_t | y, | ||
| const uint8_t * | bitmap, | ||
| uint16_t | w, | ||
| uint16_t | h, | ||
| uint16_t | color | ||
| ) |
Draw a ROM-resident 1-bit image at the specified (x,y) position, using the specified foreground color (unset bits are transparent).
| x | Top left corner x coordinate |
| y | Top left corner y coordinate |
| bitmap | byte array with monochrome bitmap |
| w | Width of bitmap in pixels |
| h | Hieght of bitmap in pixels |
| color | 16-bit 5-6-5 Color to draw with |
| void display_drawBitmapV1_bg | ( | uint16_t | x, |
| uint16_t | y, | ||
| const uint8_t * | bitmap, | ||
| uint16_t | w, | ||
| uint16_t | h, | ||
| uint16_t | color, | ||
| uint16_t | bg | ||
| ) |
Draw a ROM-resident 1-bit image at the specified (x,y) position, using the specified foreground (for set bits) and background (unset bits) colors.
| x | Top left corner x coordinate |
| y | Top left corner y coordinate |
| bitmap | byte array with monochrome bitmap |
| w | Width of bitmap in pixels |
| h | Hieght of bitmap in pixels |
| color | 16-bit 5-6-5 Color to draw pixels with |
| bg | 16-bit 5-6-5 Color to draw background with |
| void display_drawBitmapV2 | ( | uint16_t | x, |
| uint16_t | y, | ||
| const uint8_t * | bitmap, | ||
| uint16_t | w, | ||
| uint16_t | h, | ||
| uint16_t | color | ||
| ) |
Draw a ROM-resident 1-bit image at the specified (x,y) position, using the specified foreground color (unset bits are transparent).
| x | Top left corner x coordinate |
| y | Top left corner y coordinate |
| bitmap | byte array with monochrome bitmap |
| w | Width of bitmap in pixels |
| h | Hieght of bitmap in pixels |
| color | 16-bit 5-6-5 Color to draw pixels with |
| void display_drawBitmapV2_bg | ( | uint16_t | x, |
| uint16_t | y, | ||
| const uint8_t * | bitmap, | ||
| uint16_t | w, | ||
| uint16_t | h, | ||
| uint16_t | color, | ||
| uint16_t | bg | ||
| ) |
Draw a ROM-resident 1-bit image at the specified (x,y) position, using the specified foreground (for set bits) and background (unset bits) colors.
| x | Top left corner x coordinate |
| y | Top left corner y coordinate |
| bitmap | byte array with monochrome bitmap |
| w | Width of bitmap in pixels |
| h | Hieght of bitmap in pixels |
| color | 16-bit 5-6-5 Color to draw pixels with |
| bg | 16-bit 5-6-5 Color to draw background with |
| void display_drawChar | ( | uint16_t | x, |
| uint16_t | y, | ||
| uint8_t | c, | ||
| uint16_t | color, | ||
| uint16_t | bg, | ||
| uint8_t | size | ||
| ) |
Draw a single character.
| x | Bottom left corner x coordinate |
| y | Bottom left corner y coordinate |
| c | The 8-bit font-indexed character (likely ascii) |
| color | 16-bit 5-6-5 Color to draw chraracter with |
| bg | 16-bit 5-6-5 Color to fill background with (if same as color, no background) |
| size | Font magnification level, 1 is 'original' size |
| void display_drawCircle | ( | uint16_t | x0, |
| uint16_t | y0, | ||
| uint16_t | r, | ||
| uint16_t | color | ||
| ) |
Draw a circle outline.
draw circle
| x0 | Center-point x coordinate |
| y0 | Center-point y coordinate |
| r | Radius of circle |
| color | 16-bit 5-6-5 Color to draw with |
| void display_drawCircleHelper | ( | uint16_t | x0, |
| uint16_t | y0, | ||
| uint16_t | r, | ||
| uint8_t | cornername, | ||
| uint16_t | color | ||
| ) |
Quarter-circle drawer, used to do circles and roundrects.
| x0 | Center-point x coordinate |
| y0 | Center-point y coordinate |
| r | Radius of circle |
| cornername | Mask bit #1 or bit #2 to indicate which quarters of the circle we're doing |
| color | 16-bit 5-6-5 Color to draw with |
| void display_drawHLine | ( | uint16_t | x0, |
| uint16_t | y0, | ||
| uint16_t | x1, | ||
| uint16_t | color | ||
| ) |
| void display_drawLine | ( | uint16_t | x0, |
| uint16_t | y0, | ||
| uint16_t | x1, | ||
| uint16_t | y1, | ||
| uint16_t | color | ||
| ) |
Draw a line.
draw line
| x0 | Start point x coordinate |
| y0 | Start point y coordinate |
| x1 | End point x coordinate |
| y1 | End point y coordinate |
| color | 16-bit 5-6-5 Color to draw with |
| void display_drawPixel | ( | int16_t | x, |
| int16_t | y, | ||
| uint16_t | color | ||
| ) |
| void display_drawRect | ( | uint16_t | x, |
| uint16_t | y, | ||
| uint16_t | w, | ||
| uint16_t | h, | ||
| uint16_t | color | ||
| ) |
Draw a rectangle with no fill color.
draw rectangle
| x | Top left corner x coordinate |
| y | Top left corner y coordinate |
| w | Width in pixels |
| h | Height in pixels |
| color | 16-bit 5-6-5 Color to draw with |
| void display_drawRoundRect | ( | uint16_t | x, |
| uint16_t | y, | ||
| uint16_t | w, | ||
| uint16_t | h, | ||
| uint16_t | r, | ||
| uint16_t | color | ||
| ) |
Draw a rounded rectangle with no fill color.
| x | Top left corner x coordinate |
| y | Top left corner y coordinate |
| w | Width in pixels |
| h | Height in pixels |
| r | Radius of corner rounding |
| color | 16-bit 5-6-5 Color to draw with |
| void display_drawTriangle | ( | uint16_t | x0, |
| uint16_t | y0, | ||
| uint16_t | x1, | ||
| uint16_t | y1, | ||
| uint16_t | x2, | ||
| uint16_t | y2, | ||
| uint16_t | color | ||
| ) |
Draw a triangle with no fill color.
| x0 | Vertex #0 x coordinate |
| y0 | Vertex #0 y coordinate |
| x1 | Vertex #1 x coordinate |
| y1 | Vertex #1 y coordinate |
| x2 | Vertex #2 x coordinate |
| y2 | Vertex #2 y coordinate |
| color | 16-bit 5-6-5 Color to draw with |
| void display_drawVLine | ( | uint16_t | x0, |
| uint16_t | y0, | ||
| uint16_t | y1, | ||
| uint16_t | color | ||
| ) |
| void display_fillCircle | ( | uint16_t | x0, |
| uint16_t | y0, | ||
| uint16_t | r, | ||
| uint16_t | color | ||
| ) |
Draw a circle with filled color.
draw a filled circle
| x0 | Center-point x coordinate |
| y0 | Center-point y coordinate |
| r | Radius of circle |
| color | 16-bit 5-6-5 Color to fill with |
| void display_fillCircleHelper | ( | uint16_t | x0, |
| uint16_t | y0, | ||
| uint16_t | r, | ||
| uint8_t | corners, | ||
| uint16_t | delta, | ||
| uint16_t | color | ||
| ) |
Quarter-circle drawer with fill, used for circles and roundrects.
| x0 | Center-point x coordinate |
| y0 | Center-point y coordinate |
| r | Radius of circle |
| corners | Mask bits indicating which quarters we're doing |
| delta | Offset from center-point, used for round-rects |
| color | 16-bit 5-6-5 Color to fill with |
| void display_fillRect | ( | uint16_t | x, |
| uint16_t | y, | ||
| uint16_t | w, | ||
| uint16_t | h, | ||
| uint16_t | color | ||
| ) |
draw filled rectangle
draws a filled rectangle
| x0 | the x coordinate |
| y0 | the y coordinate |
| w | the width of the rectangle |
| h | the height of the rectangle |
| color | the color of the line (BLACK or WHITE) |
| void display_fillRoundRect | ( | uint16_t | x, |
| uint16_t | y, | ||
| uint16_t | w, | ||
| uint16_t | h, | ||
| uint16_t | r, | ||
| uint16_t | color | ||
| ) |
Draw a rounded rectangle with fill color.
| x | Top left corner x coordinate |
| y | Top left corner y coordinate |
| w | Width in pixels |
| h | Height in pixels |
| r | Radius of corner rounding |
| color | 16-bit 5-6-5 Color to draw/fill with |
| void display_fillTriangle | ( | uint16_t | x0, |
| uint16_t | y0, | ||
| uint16_t | x1, | ||
| uint16_t | y1, | ||
| uint16_t | x2, | ||
| uint16_t | y2, | ||
| uint16_t | color | ||
| ) |
Draw a triangle with color-fill.
| x0 | Vertex #0 x coordinate |
| y0 | Vertex #0 y coordinate |
| x1 | Vertex #1 x coordinate |
| y1 | Vertex #1 y coordinate |
| x2 | Vertex #2 x coordinate |
| y2 | Vertex #2 y coordinate |
| color | 16-bit 5-6-5 Color to fill/draw with |
| uint16_t display_getCursorX | ( | void | ) |
Get text cursor X location.
| uint16_t display_getCursorY | ( | void | ) |
Get text cursor Y location.
| uint16_t display_getHeight | ( | void | ) |
Get height of the display, accounting for the current rotation.
Get display Height.
| uint8_t display_getRotation | ( | void | ) |
Get rotation setting for display.
| uint16_t display_getWidth | ( | void | ) |
Get width of the display, accounting for the current rotation.
Get display Width.
| void display_progressbar | ( | int | x, |
| int | y, | ||
| int | length, | ||
| int | value | ||
| ) |
| void display_putc | ( | uint8_t | c | ) |
Print one byte/character of data.
| c | The 8-bit ascii character to write |
| void display_puts | ( | const uint8_t * | s | ) |
Print a string to the display.
| s | The string to write |
note use snprintf to format text snprintf does not display floating numbers use display_double() to display floating numbers
| void display_puts_max_n | ( | const uint8_t * | s, |
| uint8_t | n | ||
| ) |
Print a maximum of (n - 1) characters from the input string to the display and put "..." as the nth character afterwards to indicate that the string was truncated.
| s | The input string to write (will be truncated if longer than n characters) |
| n | The maximum number of characters (minus 1 to leave space for "...") to display from the input string NOTE: This is only the number of VISIBLE characters, so excludes NULL terminator. |
note use snprintf to format text snprintf does not display floating numbers use display_double() to display floating numbers
EXAMPLE: const char *str = "Hello, World!"; display_puts_max_n(s, 30); // Result is: Hello, World! display_puts_max_n(s, 9); // Result is: Hello, W...
| void display_setCursor | ( | uint16_t | x, |
| uint16_t | y | ||
| ) |
Set text cursor location.
| x | X coordinate in pixels |
| y | Y coordinate in pixels |
| void display_setRotation | ( | uint16_t | rotation | ) |
set the rotation prints starting at the cursor position.
| rotation | 0 == no rotation, 1 = 90 degrees |
| void display_setTextColor | ( | uint16_t | c, |
| uint16_t | b | ||
| ) |
Set text font color with custom background color.
| c | 16-bit 5-6-5 Color to draw text with |
| b | 16-bit 5-6-5 Color to draw background/fill with |
| void display_setTextSize | ( | uint8_t | s | ) |
Set text 'magnification' size.
Each increase in s makes 1 pixel that much bigger.
| s | Desired text size. 1 is default 6x8, 2 is 12x16, 3 is 18x24, etc |
| void display_setTextWrap | ( | bool | w | ) |
Whether text that is too long should 'wrap' around to the next line.
| w | Set true for wrapping, false for clipping |
| void display_slider | ( | int | x, |
| int | y, | ||
| int | length, | ||
| int | value | ||
| ) |
| void fillRect | ( | uint16_t | x0, |
| uint16_t | y0, | ||
| uint16_t | x1, | ||
| int16_t | y1, | ||
| uint16_t | color | ||
| ) |
| void printFloat | ( | float | float_n, |
| int8_t | f_width, | ||
| int8_t | decimal, | ||
| uint8_t | _flags | ||
| ) |
| uint8_t printNumber | ( | uint32_t | n, |
| int8_t | n_width, | ||
| uint8_t | _flags | ||
| ) |
| void v_printf | ( | const char * | fmt, |
| va_list | arp | ||
| ) |
| void writeLine | ( | uint16_t | x0, |
| uint16_t | y0, | ||
| uint16_t | x1, | ||
| uint16_t | y1, | ||
| uint16_t | color | ||
| ) |
Write a line.
Bresenham's algorithm - thx wikpedia
| x0 | Start point x coordinate |
| y0 | Start point y coordinate |
| x1 | End point x coordinate |
| y1 | End point y coordinate |
| color | 16-bit 5-6-5 Color to draw with |