aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2018-02-15 08:35:35 -0500
committerClyne Sullivan <tullivan99@gmail.com>2018-02-15 08:35:35 -0500
commitb0cd81cf66c0e5b5d0d662384752337f6c69cde5 (patch)
tree77604c4997981144d181af680485f523a860c101
parentf90c71412cd715e1a7293ecdb0237c96fbfe9bb8 (diff)
better drawing, landscape
-rw-r--r--include/display.h4
-rw-r--r--include/display_draw.h9
-rw-r--r--initrd/init15
-rw-r--r--src/display.c14
-rw-r--r--src/display_draw.c23
-rw-r--r--src/main.c25
6 files changed, 58 insertions, 32 deletions
diff --git a/include/display.h b/include/display.h
index 1fab223..fb808c6 100644
--- a/include/display.h
+++ b/include/display.h
@@ -3,8 +3,8 @@
#include <stdint.h>
-#define LCD_WIDTH 320
-#define LCD_HEIGHT 480
+#define LCD_WIDTH 480
+#define LCD_HEIGHT 320
#define COLOR_MAX 31
diff --git a/include/display_draw.h b/include/display_draw.h
new file mode 100644
index 0000000..1030d45
--- /dev/null
+++ b/include/display_draw.h
@@ -0,0 +1,9 @@
+#ifndef DISPLAY_DRAW_H_
+#define DISPLAY_DRAW_H_
+
+void dsp_rect(int x, int y, int w, int h, uint16_t color);
+
+void dsp_cpos(int x, int y);
+void dsp_puts(const char *s);
+
+#endif // DISPLAY_DRAW_H_
diff --git a/initrd/init b/initrd/init
index bb04364..324e519 100644
--- a/initrd/init
+++ b/initrd/init
@@ -1,10 +1,23 @@
+func div9
+ if ((arg0 % 9) == 0)
+ ret 1
+ end
+ ret 0
+end
+
set a 0
+set b 0
do
set a (a + 1)
+ div9 a > b
+ if (b)
+ print a
+ print ", "
+ end
delay 1
while (a < 100)
if (a == 100)
- print "All good!"
+ print " All good!"
end
diff --git a/src/display.c b/src/display.c
index 9600ec0..8b62e6a 100644
--- a/src/display.c
+++ b/src/display.c
@@ -145,18 +145,10 @@ void dsp_init(void)
dsp_write_cmd(0xC5); // frame rate/inversion ctl
dsp_write_data(0x03);
- // backlight
- dsp_write_cmd(0x55);
- dsp_write_data(0x01);
- dsp_write_cmd(0x53);
- dsp_write_data(0x2C);
- dsp_write_cmd(0x51);
- dsp_write_data(0x01);
-
dsp_write_cmd(0x36); // rot. and stuff
- dsp_write_data(0x41);
+ dsp_write_data(0xA3);
dsp_write_cmd(0x3A); // set pixel format
- dsp_write_data(0x65);
+ dsp_write_data(0x55);
dsp_write_cmd(0x11);
delay(150);
dsp_write_cmd(0x29); // set display on
@@ -171,7 +163,5 @@ void dsp_init(void)
dsp_write_cmd(0x37);
dsp_write_data(0x00);
dsp_write_data(0x00);*/
-
- dsp_set_addr(0, 0, LCD_WIDTH, LCD_HEIGHT);
}
diff --git a/src/display_draw.c b/src/display_draw.c
index 84a5443..f52cd8e 100644
--- a/src/display_draw.c
+++ b/src/display_draw.c
@@ -17,8 +17,11 @@ void dsp_putchar(int c)
dsp_write_data(inconsolata24[start + (i * 192 * 2) + j]);
}
- if (++curx == 26)
- curx = 0, cury++;
+ if (++curx == 40) {
+ curx = 0;
+ if (++cury == 10)
+ cury = 0;
+ }
}
void dsp_puts(const char *s)
@@ -27,3 +30,19 @@ void dsp_puts(const char *s)
while (s[i])
dsp_putchar(s[i++]);
}
+
+void dsp_cpos(int x, int y)
+{
+ curx = x;
+ cury = y;
+}
+
+void dsp_rect(int x, int y, int w, int h, uint16_t color)
+{
+ dsp_set_addr(x, y, x + w - 1, y + h - 1);
+ int countdown = w * h;
+ do {
+ dsp_write_data(color >> 8);
+ dsp_write_data(color & 0xFF);
+ } while (countdown--);
+}
diff --git a/src/main.c b/src/main.c
index b91a975..bab8f02 100644
--- a/src/main.c
+++ b/src/main.c
@@ -5,6 +5,7 @@
#include <gpio.h>
#include <lcd.h>
#include <display.h>
+#include <display_draw.h>
#include <initrd.h>
#include <serial.h>
#include <parser.h>
@@ -43,8 +44,8 @@ int main(void)
int script_puts(interpreter *it)
{
char *s = igetarg_string(it, 0);
- //lcd_puts(s);
- asm("mov r0, %0; svc 2" :: "r" (s));
+ dsp_puts(s);
+ //asm("mov r0, %0; svc 2" :: "r" (s));
return 0;
}
@@ -102,23 +103,17 @@ void kmain(void)
asm("cpsie i");
dsp_init();
- //uint16_t c = 0x38;
- uint16_t c = 0;
- for (int i = 0; i < LCD_HEIGHT; i++) {
- dsp_set_addr(0, i, LCD_WIDTH - 1, i);
- int w = LCD_WIDTH - 1;
- do {
- dsp_write_data(c);//c >> 8);
- dsp_write_data(c);//c & 0xFF);
- } while (w--);
- }
- extern void dsp_puts(const char *);
- dsp_puts("Hello, world! My name is Clyne.");
+ dsp_rect(0, 0, LCD_WIDTH, 105, dsp_color(0xFF, 0, 0));
+ dsp_rect(0, 105, LCD_WIDTH, 105, dsp_color(0, 0xFF, 0));
+ dsp_rect(0, 210, LCD_WIDTH, 110, dsp_color(0, 0, 0xFF));
+
+ //dsp_puts("Hello, world! My name is Clyne. I enjoy car rides and long
+//walks on the beach");
//task_start(lcd_handler, 128);
//delay(200);
- //task_start(task_interpreter, 4096);
+ task_start(task_interpreter, 4096);
//char *s = initrd_getfile("test.txt");