mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
Ion simulator support
This commit is contained in:
21
ion/drivers/fltklcd/fltklcd.cpp
Normal file
21
ion/drivers/fltklcd/fltklcd.cpp
Normal 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;
|
||||
}
|
||||
13
ion/drivers/fltklcd/fltklcd.h
Normal file
13
ion/drivers/fltklcd/fltklcd.h
Normal 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
|
||||
@@ -9,6 +9,8 @@ void ion_init();
|
||||
void ion_display_on();
|
||||
void ion_display_off();
|
||||
|
||||
void ion_sleep();
|
||||
|
||||
char ion_getchar();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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
|
||||
|
||||
11
ion/platform/simulator/framebuffer.h
Normal file
11
ion/platform/simulator/framebuffer.h
Normal 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
|
||||
@@ -1,4 +0,0 @@
|
||||
#include <ion.h>
|
||||
|
||||
void ion_init() {
|
||||
}
|
||||
35
ion/platform/simulator/init.cpp
Normal file
35
ion/platform/simulator/init.cpp
Normal 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();
|
||||
}
|
||||
10
ion/platform/simulator/keyboard.c
Normal file
10
ion/platform/simulator/keyboard.c
Normal 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;
|
||||
}
|
||||
4
ion/platform/simulator/platform.cpp
Normal file
4
ion/platform/simulator/platform.cpp
Normal file
@@ -0,0 +1,4 @@
|
||||
#include "platform.h"
|
||||
|
||||
platform_t Platform;
|
||||
void * PlatformFramebuffer;
|
||||
15
ion/platform/simulator/platform.h
Normal file
15
ion/platform/simulator/platform.h
Normal 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
|
||||
Reference in New Issue
Block a user