Ion simulator support

This commit is contained in:
Romain Goyet
2015-09-01 11:39:02 +02:00
parent d70d3b4e4a
commit cd3046b3ef
10 changed files with 116 additions and 6 deletions

View File

@@ -0,0 +1,21 @@
#include "fltklcd.h"
#include <stdlib.h>
#include <stdio.h> // FIXME: remove printfs
#include <FL/Fl_draw.H>
FltkLCD::FltkLCD(int x, int y, int w, int h) : Fl_Widget(x, y, w, h, NULL) {
m_framebuffer = malloc(w*h);
// FIXME: Delete the framebuffer!
}
void FltkLCD::draw() {
printf("DRAW\n");
fl_draw_image_mono((const uchar *)m_framebuffer,
0, // x
0, // y
w(), // width
h(), // height,
1, // byte-delta between pixels
0); // byte-delta between lines;
}

View File

@@ -0,0 +1,13 @@
#ifndef ION_FLTK_LCD
#define ION_FLTK_LCD
#include <FL/Fl_Widget.H>
class FltkLCD : public Fl_Widget {
public:
FltkLCD(int x, int y, int w, int h);
void draw();
void * m_framebuffer;
};
#endif

View File

@@ -9,6 +9,8 @@ void ion_init();
void ion_display_on();
void ion_display_off();
void ion_sleep();
char ion_getchar();
#endif

View File

@@ -1,2 +1,5 @@
objs += $(addprefix ion/src/platform/simulator/, init.o)
#objs += $(addprefix ion/src/drivers/, ili9341/ili9341.o fx92kbd/fx92kbd.o)
objs += $(addprefix ion/platform/simulator/, init.o keyboard.o platform.o)
objs += $(addprefix ion/drivers/, fltklcd/fltklcd.o)
#SFLAGS += -I/usr/local/Cellar/fltk/1.3.3/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_THREAD_SAFE -D_REENTRANT
LDFLAGS += -L/usr/local/Cellar/fltk/1.3.3/lib -lfltk -lpthread -framework Cocoa

View File

@@ -0,0 +1,11 @@
#ifndef ION_SIMULATOR_FRAMEBUFFER_H
#define ION_SIMULATOR_FRAMEBUFFER_H
extern void * PlatformFramebuffer;
#define ION_FRAMEBUFFER_ADDRESS PlatformFramebuffer
#define ION_FRAMEBUFFER_WIDTH 320
#define ION_FRAMEBUFFER_HEIGHT 240
#define ION_FRAMEBUFFER_BITS_PER_PIXEL 8
#endif

View File

@@ -1,4 +0,0 @@
#include <ion.h>
void ion_init() {
}

View File

@@ -0,0 +1,35 @@
extern "C" {
#include <ion.h>
#include <assert.h>
#include <stdio.h>
}
#include "platform.h"
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <ion/drivers/fltklcd/fltklcd.h>
void ion_init() {
Fl_Window * window = new Fl_Window(360, 280);
#if 1
FltkLCD * lcd = new FltkLCD(20, 20, 320, 240);
assert(ION_FRAMEBUFFER_BITS_PER_PIXEL == 8);
Platform.display = lcd;
PlatformFramebuffer = lcd->m_framebuffer;
#else
Fl_Box * box = new Fl_Box(20,20,320,240,"Hello, World!");
box->box(FL_UP_BOX);
box->labelfont(FL_BOLD+FL_ITALIC);
box->labelsize(36);
box->labeltype(FL_SHADOW_LABEL);
#endif
window->end();
window->show(NULL, NULL);
//Fl::run();
}
void ion_sleep() {
printf("ion_sleep\n");
Platform.display->redraw();
Fl::wait();
}

View File

@@ -0,0 +1,10 @@
#include <ion.h>
#include <stdio.h>
char ion_getchar() {
printf("GETCHAR\n");
ion_sleep();
char c = getchar();
printf("Returning %c\n", c);
return c;
}

View File

@@ -0,0 +1,4 @@
#include "platform.h"
platform_t Platform;
void * PlatformFramebuffer;

View File

@@ -0,0 +1,15 @@
#ifndef ION_SIMULATOR_PLATFORM_H
#define ION_SIMULATOR_PLATFORM_H
#include <ion/drivers/fltklcd/fltklcd.h>
extern "C" {
#include "framebuffer.h"
}
typedef struct {
FltkLCD * display;
} platform_t;
extern platform_t Platform;
#endif