better drawing, landscape

master
Clyne Sullivan 7 years ago
parent f90c71412c
commit b0cd81cf66

@ -3,8 +3,8 @@
#include <stdint.h> #include <stdint.h>
#define LCD_WIDTH 320 #define LCD_WIDTH 480
#define LCD_HEIGHT 480 #define LCD_HEIGHT 320
#define COLOR_MAX 31 #define COLOR_MAX 31

@ -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_

@ -1,6 +1,19 @@
func div9
if ((arg0 % 9) == 0)
ret 1
end
ret 0
end
set a 0 set a 0
set b 0
do do
set a (a + 1) set a (a + 1)
div9 a > b
if (b)
print a
print ", "
end
delay 1 delay 1
while (a < 100) while (a < 100)

@ -145,18 +145,10 @@ void dsp_init(void)
dsp_write_cmd(0xC5); // frame rate/inversion ctl dsp_write_cmd(0xC5); // frame rate/inversion ctl
dsp_write_data(0x03); 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_cmd(0x36); // rot. and stuff
dsp_write_data(0x41); dsp_write_data(0xA3);
dsp_write_cmd(0x3A); // set pixel format dsp_write_cmd(0x3A); // set pixel format
dsp_write_data(0x65); dsp_write_data(0x55);
dsp_write_cmd(0x11); dsp_write_cmd(0x11);
delay(150); delay(150);
dsp_write_cmd(0x29); // set display on dsp_write_cmd(0x29); // set display on
@ -171,7 +163,5 @@ void dsp_init(void)
dsp_write_cmd(0x37); dsp_write_cmd(0x37);
dsp_write_data(0x00); dsp_write_data(0x00);
dsp_write_data(0x00);*/ dsp_write_data(0x00);*/
dsp_set_addr(0, 0, LCD_WIDTH, LCD_HEIGHT);
} }

@ -17,8 +17,11 @@ void dsp_putchar(int c)
dsp_write_data(inconsolata24[start + (i * 192 * 2) + j]); dsp_write_data(inconsolata24[start + (i * 192 * 2) + j]);
} }
if (++curx == 26) if (++curx == 40) {
curx = 0, cury++; curx = 0;
if (++cury == 10)
cury = 0;
}
} }
void dsp_puts(const char *s) void dsp_puts(const char *s)
@ -27,3 +30,19 @@ void dsp_puts(const char *s)
while (s[i]) while (s[i])
dsp_putchar(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--);
}

@ -5,6 +5,7 @@
#include <gpio.h> #include <gpio.h>
#include <lcd.h> #include <lcd.h>
#include <display.h> #include <display.h>
#include <display_draw.h>
#include <initrd.h> #include <initrd.h>
#include <serial.h> #include <serial.h>
#include <parser.h> #include <parser.h>
@ -43,8 +44,8 @@ int main(void)
int script_puts(interpreter *it) int script_puts(interpreter *it)
{ {
char *s = igetarg_string(it, 0); char *s = igetarg_string(it, 0);
//lcd_puts(s); dsp_puts(s);
asm("mov r0, %0; svc 2" :: "r" (s)); //asm("mov r0, %0; svc 2" :: "r" (s));
return 0; return 0;
} }
@ -102,23 +103,17 @@ void kmain(void)
asm("cpsie i"); asm("cpsie i");
dsp_init(); 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_rect(0, 0, LCD_WIDTH, 105, dsp_color(0xFF, 0, 0));
dsp_puts("Hello, world! My name is Clyne."); 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); //task_start(lcd_handler, 128);
//delay(200); //delay(200);
//task_start(task_interpreter, 4096); task_start(task_interpreter, 4096);
//char *s = initrd_getfile("test.txt"); //char *s = initrd_getfile("test.txt");

Loading…
Cancel
Save