Skip to content

Commit

Permalink
Final version v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pstadler1990 authored Jun 9, 2020
1 parent 5968e04 commit f583f17
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 41 deletions.
4 changes: 1 addition & 3 deletions communication.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ uart_send_command(UART_CTRL_COMMAND command, bool timed) {
receiveStatus = uart_receive(receiveBuf, 10);
if(receiveStatus) {

printf("rx: %s\n", receiveBuf);

if(strncmp("OK", receiveBuf, 2) == 0) {
return 1;
}
Expand Down Expand Up @@ -135,4 +133,4 @@ com_get_display_name(char* nameBuf, size_t nameBufSize) {
}

return 1;
}
}
2 changes: 1 addition & 1 deletion configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#define RESULT_OUTPUT_DIR "results"

#define SHUTDOWN_PRESS_TIME ((uint32_t)1000000) /* ~5s */
#define SHUTDOWN_PRESS_TIME ((uint32_t)10000000)

/* GPIOs */
#define GPIO_EXT_TRIGGER_IN ((unsigned int)5) /* Physical pin 29, BCM pin 5 */
Expand Down
9 changes: 7 additions & 2 deletions fb_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ fb_init(const char* fb_dev_id, struct FbDev* fb_device) {
fb_device->bpp = vinfo.bits_per_pixel;
fb_device->linelen = finfo.line_length;
fb_device->memlen = finfo.smem_len;
fb_device->timing = vinfo.left_margin;

/* Map memory */
fb_device->fbuf = (char *)mmap(0, finfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb_device->fb_fd, 0);
Expand Down Expand Up @@ -151,7 +152,11 @@ fb_draw_text(const struct FbDev* fb_device, const char* text, int32_t x, int32_t

void
fb_draw_filled_screen(const struct FbDev* fb_device, uint32_t color) {
memset(fb_device->bbuf, color, fb_device->memlen);
if(color == COLOR_WHITE) {
memset(fb_device->bbuf, color, fb_device->memlen);
} else {
fb_draw_rect(fb_device, 0, 0, fb_device->w, fb_device->h, color, DRAW_CENTER_NONE);
}
}

void
Expand Down Expand Up @@ -218,4 +223,4 @@ _put_pixel(const struct FbDev* fb_device, uint32_t x, uint32_t y, uint32_t color
uint32_t
_get_memory_location(const struct FbDev* fb_device, uint32_t ox, uint32_t oy) {
return ox * fb_device->bpp / 8 + oy * fb_device->linelen;
}
}
1 change: 1 addition & 0 deletions fb_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct FbDev {
int fb_fd; /* File descriptor */
uint32_t w; /* Visible screen width */
uint32_t h; /* Visible screen height */
uint32_t timing;
uint32_t bpp; /* Bits per pixel (color depth) */
uint32_t linelen; /* Pre-calculated horizontal length */
uint32_t memlen; /* Pre-calculated memory size */
Expand Down
5 changes: 4 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,22 @@

struct FbDevState framebuf_state = {
.state = FBSTATE_INITIALIZE,
.homesw_mode = 0,
.n_measurements = DEFAULT_N_MEASUREMENTS,
.mode = FBMODE_HOME,
.colorm = FBCOLOR_B2W,
.isCalibrated = false,
};
int uart0_filestream = -1;

bool mainIsRunning = true;
bool usbDriveInserted = false;
bool usbDriveCopied = false;
struct FbDev framebuf_device;

int
main() {
struct FbDev framebuf_device;
// struct FbDev framebuf_device;

if(!fb_init("/dev/fb0", &framebuf_device)) {
perror("Could not access framebuffer, exit");
Expand Down
8 changes: 8 additions & 0 deletions main.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,17 @@ typedef enum {
FBMODE_CALIB,
} FB_MODE;

typedef enum {
FBCOLOR_B2W,
FBCOLOR_B2R,
FBCOLOR_R2G
} FB_COLORMODE;

struct FbDevState {
FB_STATE state; /* Internal state machine */
FB_MODE mode; /* Internal mode */
FB_COLORMODE colorm; /* Color mode */
uint8_t homesw_mode;
uint32_t n_measurements; /* Number of measurements per series, default = 100 */

bool isCalibrated;
Expand Down
1 change: 1 addition & 0 deletions menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ menu_switch_pressed(void) {
homeSwitchPressedTime = 0;
framebuf_state.mode = FBMODE_HOME;
framebuf_state.state = FBSTATE_IDLE;
framebuf_state.homesw_mode = !framebuf_state.homesw_mode;
}

void
Expand Down
1 change: 0 additions & 1 deletion menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ typedef enum {
void menu_switch_pressed(void);
void calib_switch_pressed(void);
void start_switch_pressed(void);
void shutdown_switch_pressed(void);
void* menu_poll(void* vargp);
void* usbdrive_poll(void* vargp);

Expand Down
Loading

0 comments on commit f583f17

Please sign in to comment.