mirror of
https://github.com/travisgoodspeed/goodwatch
synced 2024-11-21 23:58:31 +00:00
Beginnings of a DMESG app. No transmissions yet. #94
This commit is contained in:
parent
c015141869
commit
6cb0402308
@ -12,6 +12,7 @@ MORSE_APP = 1
|
||||
BEACON_APP = 1
|
||||
OOK_APP = 1
|
||||
COUNTER_APP = 1
|
||||
DMESG_APP = 1
|
||||
|
||||
#set default flashing serial port, dont override if passed in as an argument
|
||||
PORT = /dev/ttyUSB0
|
||||
@ -27,6 +28,10 @@ ifeq ($(SHABBAT_APP),1)
|
||||
APPS_OBJ += apps/shabbat.o
|
||||
APPS_DEFINES += SHABBAT_APP
|
||||
endif
|
||||
ifeq ($(DMESG_APP),1)
|
||||
APPS_OBJ += apps/dmesg.o
|
||||
APPS_DEFINES += DMESG_APP
|
||||
endif
|
||||
ifeq ($(RPN_APP),1)
|
||||
APPS_OBJ += apps/rpn.o
|
||||
APPS_DEFINES += RPN_APP
|
||||
|
@ -51,13 +51,7 @@ const struct app subapps[]={
|
||||
.keypress=rpn_keypress
|
||||
},
|
||||
#endif
|
||||
|
||||
#ifdef HEX_APP
|
||||
//Hex Viewer.
|
||||
{.name="hex edit", .init=hex_init, .draw=hex_draw, .exit=hex_exit,
|
||||
.keypress=hex_keypress
|
||||
},
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef ALARM_APP
|
||||
//Alarm
|
||||
@ -66,6 +60,21 @@ const struct app subapps[]={
|
||||
},
|
||||
#endif
|
||||
|
||||
#ifdef HEX_APP
|
||||
//Hex Viewer.
|
||||
{.name="hex edit", .init=hex_init, .draw=hex_draw, .exit=hex_exit,
|
||||
.keypress=hex_keypress
|
||||
},
|
||||
#endif
|
||||
|
||||
#ifdef DMESG_APP
|
||||
//DMESG Viewer
|
||||
{.name="dmesg", .init=dmesgapp_init, .draw=dmesgapp_draw, .exit=dmesgapp_exit,
|
||||
.keypress=dmesgapp_keypress
|
||||
},
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef SHABBAT_APP
|
||||
//Kosher applet for Shabbat that disables all inputs except the SET button.
|
||||
{.name="shabbat ", .init=shabbat_init, .draw=shabbat_draw, .exit=shabbat_exit,
|
||||
|
@ -18,6 +18,7 @@ extern const struct app clock_applet;
|
||||
#include "apps/phrase.h"
|
||||
#include "apps/rngapp.h"
|
||||
#include "apps/shabbat.h"
|
||||
#include "apps/dmesg.h"
|
||||
|
||||
//Then radio apps.
|
||||
#include "apps/morse.h"
|
||||
|
102
firmware/apps/dmesg.c
Normal file
102
firmware/apps/dmesg.c
Normal file
@ -0,0 +1,102 @@
|
||||
/*! \file hex.c
|
||||
\brief Hex Viewer
|
||||
|
||||
This is a simple viewer application for watching the dmesg buffer.
|
||||
Later on, we might add support for beaconing the log over RF.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//MSP430 functions for the SFRIE.
|
||||
#include <msp430.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
//Include all standard GoodWatch functions.
|
||||
#include "api.h"
|
||||
|
||||
#include "apps/dmesg.h"
|
||||
|
||||
//! Our index within the buffer.
|
||||
static uint16_t index=0;
|
||||
|
||||
//! Entry to the hex editor app.
|
||||
void dmesgapp_init(){
|
||||
/* This function is called whenever the app is selected by the Mode
|
||||
button. We don't initialize the address here, because we don't
|
||||
want to have it reset, but we do disable some interrupts that
|
||||
could trigger a crash on data reads.
|
||||
*/
|
||||
//Force drawing the first frame.
|
||||
dmesgapp_draw(1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//! Exit from the hex editor app.
|
||||
int dmesgapp_exit(){
|
||||
/* This function is called whenever the Mode button on the right
|
||||
side of the watch is pressed. If we return 1, it means that our
|
||||
own app is using the button, so we return 0 to indicate that the
|
||||
task manager is welcome to switch to the next app.
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
//! A button has been pressed for the hex editor.
|
||||
int dmesgapp_keypress(char ch){
|
||||
//Handle the input that we received by an event.
|
||||
switch(ch){
|
||||
case '7':// Press 7 to transmit the buffer.
|
||||
lcd_zero();
|
||||
lcd_string("TRANSMIT");
|
||||
return 0; //We'll redraw when the button is released.
|
||||
case '.':// Press . to clear the buffer.
|
||||
lcd_zero();
|
||||
dmesg_clear();
|
||||
lcd_string("CLEARED");
|
||||
return 0;
|
||||
case '0':// Press 0 to return to the start of the buffer.
|
||||
index=0;
|
||||
break;
|
||||
}
|
||||
|
||||
//Force a redraw out-of-frame.
|
||||
return 1;
|
||||
}
|
||||
|
||||
//! Draws a bit of the buffer.
|
||||
static void dmesgapp_drawbuffer(int offset){
|
||||
char fragment[8];
|
||||
int i;
|
||||
|
||||
memcpy(fragment, dmesg_buffer+offset, 8);
|
||||
for(i=0;i<8;i++)
|
||||
if(fragment[i]>0x7f || !fragment[i])
|
||||
fragment[i]=0x20;
|
||||
|
||||
lcd_zero();
|
||||
lcd_string(fragment);
|
||||
}
|
||||
|
||||
|
||||
//! Draw the hex editor app.
|
||||
void dmesgapp_draw(int forced){
|
||||
/* This is called four times per second to render the display. The
|
||||
CPU is running at 32kHz until we tell it otherwise, so it's best
|
||||
not to do anything too fancy in a single rendering.
|
||||
|
||||
Our screen is double-buffered, so the user won't notice it all
|
||||
being drawn.
|
||||
*/
|
||||
if(forced || !key_pressed()){
|
||||
//Draw eight bytes.
|
||||
dmesgapp_drawbuffer(index++);
|
||||
|
||||
//Jump to beginning after we catch up with the current pointer.
|
||||
if(index>dmesg_index)
|
||||
index=0;
|
||||
}
|
||||
}
|
13
firmware/apps/dmesg.h
Normal file
13
firmware/apps/dmesg.h
Normal file
@ -0,0 +1,13 @@
|
||||
/*! \file dmesg.h
|
||||
\brief Dmesg viewer application.
|
||||
*/
|
||||
|
||||
//! Enter the dmesg editor.
|
||||
void dmesgapp_init();
|
||||
//! Exit the dmesg editor.
|
||||
int dmesgapp_exit();
|
||||
//! Draw the screen.
|
||||
void dmesgapp_draw(int forced);
|
||||
|
||||
//! A button has been pressed for the dmesg editor.
|
||||
int dmesgapp_keypress(char ch);
|
@ -8,7 +8,8 @@
|
||||
extern uint32_t dmesg_magic;
|
||||
//! Index within that buffer.
|
||||
extern uint16_t dmesg_index;
|
||||
|
||||
//! Buffer itself.
|
||||
extern char *dmesg_buffer;
|
||||
|
||||
//! Clears the dmesg buffer.
|
||||
void dmesg_clear();
|
||||
|
Loading…
Reference in New Issue
Block a user