+/rtos

git clone https://git.julia.blue/+/rtos

Vivek MalneediMerge branch 'master' of github.com:EE445M-Sp20/lab-6-vm22967_jbr2558021d2d4

master
6.3 KiB159 linesraw
1// Driver written by Limor Fried aka Ladyada for Adafruit Industries.
2
3// Adafruit ST7735 breakout -> TM4C pins
4// SCK -> PA2
5// TFT_CS -> PA3
6// MISO -> PA4
7// MOSI -> PA5
8// COMMAND/DATA -> PA6
9// RESET -> PA7
10// CARD_CS -> PB0
11
12#pragma once
13
14#include <stdbool.h>
15#include <stdint.h>
16
17#define ST7735_WIDTH 128
18#define ST7735_HEIGHT 160
19
20#define LCD_BLACK 0x0000
21#define LCD_BLUE 0xF800
22#define LCD_RED 0x001F
23#define LCD_GREEN 0x07E0
24#define LCD_CYAN 0xFFE0
25#define LCD_MAGENTA 0xF81F
26#define LCD_YELLOW 0x07FF
27#define LCD_WHITE 0xFFFF
28
29// Initialization for ST7735R screens (green or red tabs).
30void lcd_init();
31
32typedef uint16_t Color;
33
34// convert 24 bit color to the 16 bit BGR format used by the ST7735
35Color rgb(uint8_t r, uint8_t g, uint8_t b);
36// convert packed color (0x00RRGGBB) to the 16 bit format;
37Color rgb_packed(uint32_t packed_color);
38
39// Color the pixel at the given coordinates with the given color.
40// Requires 13 bytes of transmission
41// Input: x     horizontal position of the pixel, columns from the left edge
42//               must be less than 128
43//               0 is on the left, 126 is near the right
44//        y     vertical position of the pixel, rows from the top edge
45//               must be less than 160
46//               159 is near the wires, 0 is the side opposite the wires
47//        color 16-bit color in BGR 5-6-5 format
48void lcd_pixel(int16_t x, int16_t y, Color color);
49
50// Draw a vertical line at the given coordinates with the given height and
51// color. A vertical line is parallel to the longer side of the rectangular
52// display Requires (11 + 2*h) bytes of transmission (assuming image fully on
53// screen)
54void lcd_fast_vline(int16_t x, int16_t y, int16_t h, Color color);
55
56// Draw a horizontal line at the given coordinates with the given width and
57// color. A horizontal line is parallel to the shorter side of the rectangular
58// display Requires (11 + 2*w) bytes of transmission (assuming image fully on
59// screen)
60void lcd_fast_hline(int16_t x, int16_t y, int16_t w, Color color);
61
62// Input: color 16-bit color in BGR 5-6-5 format
63void lcd_fill(Color color);
64
65// Draw a filled rectangle at the given coordinates with the given width,
66// height, and color. Requires (11 + 2*w*h) bytes of transmission (assuming
67// image fully on screen)
68// Input: x     horizontal position of the top left corner of the rectangle,
69//              columns from the left edge
70//        y     vertical position of the top left corner of the rectangle, rows
71//              from the top edge
72//        w     horizontal width of the rectangle
73//        h     vertical height of the rectangle
74//        color 16-bit color in BGR 5-6-5 format
75void lcd_rect(int16_t x, int16_t y, int16_t w, int16_t h, Color color);
76
77// Displays a 16-bit color bitmap.
78// array image[] has one 16-bit color for each pixel to be
79// displayed on the screen (encoded in reverse order, which is
80// standard for bitmap files)
81// (x,y) is the screen location of the lower left corner of BMP image
82// Requires (11 + 2*w*h) bytes of transmission (assuming image fully on screen)
83// Input: x     horizontal position of the bottom left corner of the image,
84//              columns from the left edge
85//        y     vertical position of the bottom left corner of the image, rows
86//              from the top edge
87//        image pointer to a 16-bit color image data
88//        w     number of pixels wide
89//        h     number of pixels tall
90// Must be less than or equal to 128 pixels wide by 160 pixels high
91void lcd_bitmap(int16_t x, int16_t y, const uint16_t* image, int16_t w,
92                int16_t h);
93
94// If the background color is the same as the text color, no background will be
95// printed, and text can be drawn right over existing images without covering
96// them with a box. Requires (11 + 2*size*size)*6*8 (image fully on screen;
97// textcolor != bgColor)
98// Input: x         horizontal position of the top left corner of the character,
99//                  columns from the left edge
100//        y         vertical position of the top left corner of the character,
101//                  rows from the top edge
102//        c         character to be printed
103//        textColor 16-bit color of the character
104//        bgColor   16-bit color of the background
105//        size      number of pixels per character pixel (e.g. size==2 prints
106//        each pixel of font as 2x2 square)
107void lcd_char(int16_t x, int16_t y, char c, int16_t textColor, int16_t bgColor,
108              uint8_t size);
109
110// String draw function.
111// 16 rows (0 to 15) and 21 characters (0 to 20)
112// Requires (11 + size*size*6*8) bytes of transmission for each character
113// Input: x         columns from the left edge (0 to 20)
114//        y         rows from the top edge (0 to 15)
115//        pt        pointer to a null terminated string to be printed
116//        textColor 16-bit color of the characters
117// bgColor is Black and size is 1
118// Output: number of characters printed
119uint32_t lcd_string(uint16_t x, uint16_t y, char* pt, int16_t textColor);
120
121// Move the cursor to the desired X- and Y-position.  The
122// next character will be printed here.  X=0 is the leftmost
123// column.  Y=0 is the top row.
124// Input: newX  new X-position of the cursor (0<=newX<=20)
125//        newY  new Y-position of the cursor (0<=newY<=15)
126void lcd_set_cursor(uint32_t newX, uint32_t newY);
127
128// Output a 32-bit number in unsigned decimal format
129// Input: 32-bit number to be transferred
130void lcd_num(uint32_t n);
131
132// String draw and number output.
133// Input: device  0 is on top, 1 is on bottom
134//        line    row from top, 0 to 7 for each device
135//        pt      pointer to a null terminated string to be printed
136//        value   signed integer to be printed
137void lcd_message_num(uint32_t d, uint32_t l, char* pt, int32_t value);
138
139// String draw
140// Input: device  0 is on top, 1 is on bottom
141//        line    row from top, 0 to 7 for each device
142//        pt      pointer to a null terminated string to be printed
143void lcd_message(uint32_t d, uint32_t l, char* pt);
144
145// Send the command to invert all of the colors.
146// Requires 1 byte of transmission
147// Input: false to disable inversion, true to enable inversion
148void lcd_invert(bool i);
149
150// Output one character
151void lcd_putchar(char ch);
152
153// Print a string of characters
154// The string will not automatically wrap
155void lcd_puts(const char* str);
156
157// Sets the color in which characters will be printed
158// Background color is fixed at black
159void lcd_set_text_color(Color color);