* Temperature sensor: drivers/tsensor.c [COMPLETED]
* OLED display [PLANNED]
* Joystick: drivers/mk450_joystick.c [COMPLETED]
- * TFT Screen: [PLANNED]
+ * TFT Screen: drivers/st7735s.c, include/libs/fonts/wogfont.h [IN PROGRESS]
* Memory Management [IN PROGRESS] -- FILE: lib/pool.c
* User Mode [PLANNED]
* System Call PendV implementation [PLANNED]
* Multiple processes and scheduling [PLANNED]
## SCREENSHOTS
-Here is a screenshot that shows the terminal just after booting:
+Here are some screenshots that shows the terminal just after booting:
-![Screenshot](https://github.com/robinkrens/cortex-from-scratch/raw/master/img/screenshot.png "screenshot")
+* Serial (over UART)
+![Screenshot](https://github.com/robinkrens/cortex-from-scratch/raw/master/img/serial.png "serial terminal screenshot")
+
+* TFT screen output (SPI):
+![Screenshot](https://github.com/robinkrens/cortex-from-scratch/raw/master/img/tft.png "tft peripheral screenshot")
* Initial version
*
* $DESCRIPTION$
+ * Basic driver for the ST7735s TFT screen. Initializes the screen
+ * Low-level commands can be called by tft_command. See header (.h)
+ * file for an overview of all commands. tft_command can accepts
+ * an unlimited amount of data or parameter commands.
*
* $USAGE$
+ * I added the following functionality:
+ * a. tft_fill: fills a certain area of the screen
+ * b. tft_setpixel: sets a single pixel
+ * c. tft_putc, tft_put: outputs a char/string to the screen, starts
+ * at the upper top right and tracks the position. If the screen is
+ * full, it 'scrolls' automatically. So you basically have a mini
+ * sized terminal. You can link standard output to this function!
*
* */
#define YPOS(y) (y * 8)
#define BUFFER 352
+
static struct {
uint16_t cpos;
uint8_t * textmemptr;
}
+/* Basic puts function that loops over a string */
int tft_puts(char * str) {
for (int i = 0; i < strlen(str); i++) {
}
+/* Used by scroll function to overwrite and clear the last
+ * line on the screen */
void tft_clrln() {
tft_puts(" ");
/* Scroll the buffer */
memcpy(tftscreen.textmemptr, tftscreen.textmemptr + 21, BUFFER - 21);
- //for (int i = 21; i >= 0; i--)
tftscreen.buf[BUFFER - 21] = '\0';
tftscreen.x = 0;
tftscreen.y = 0;
tftscreen.cpos = 0;
- //for (int i = 0; i < 320; i++) {
- // uart_putc(tftscreen.buf[i]);
- //}
-
tft_puts(tftscreen.buf); // CHECK: ending
- //tftscreen.y = 14;
- //tft_puts(" ");
tftscreen.y = 14;
tftscreen.x = 0;
tftscreen.cpos = BUFFER - 21;
- // DINOSAUR tft_clrln();
}
+/* Fills a line with blank characters, returns to
+ * the next line */
void tft_nl() {
uint8_t blanks = 21 - tftscreen.x;
* Should not be used directly */
int tft_putc(uint16_t fg, uint16_t bg, int c) {
-
int totalpixels = 35;
int column = 0;
int row = 0;
uint8_t current;
-
- //if ((c == '\n') && (tftscreen.y == 14)) {
- // tft_nl();
- // tft_scroll2();
- // return 1;
- //}
-
if (c == '\n') {
if (tftscreen.y == 14) {
tft_nl();
return 1;
}
}
- //// else {
- //// tft_putc(0xFFFF, 0x0000, 'o');
- //// }
- // //else {
- // // ENDFLAG = true;
- // //}
- //}
if (tftscreen.y >= 15) {
tft_scroll();
- //if (ENDFLAG) {
- // ENDFLAG = false;
- // return 1;
- //}
}
tft_command(TFT_CASET, 4, 0x00, STARTX + XPOS(tftscreen.x), 0x00, (STARTX + 4) + XPOS(tftscreen.x));
* Initial version
*
* $DESCRIPTION$
- * The classic wogfont is back!
- * Designed by Robin Krens
- * 5 by 7 bit font (lower case)
+ * A non-standard 5 by 7 bit font (ALL CHARs ARE UPPER CASE)
+ * Some characters I haven't designed yet, these will display
+ * a'█' on a VGA or TFT screen. A character is column hex-coded.
+ *
+ * An example to make things clear!
+ * The letter 'S's bitmap is:
+ *
+ * WIDTH = 5
+ * ##### L
+ * #___# E
+ * #____ N
+ * ##### G
+ * ____# T
+ * #___# H
+ * ##### = 7
+ *
+ * # represents a selected bit, 1
+ * _ represents a non selected bit, 0
+ *
+ * For example, the first column is 1111101, the second columm 1001001
+ * For hex encoding we start at the MSB, the first LSB is never used
+ * The first column is 0xF6 and the second column 0x92. The letter 'S'
+ * equals to: 0xF6, 0x92, 0x92, 0x92, 0xDE,
+ *
* */
const uint8_t ASCII5x7[] = {