Some stuff we probably want in the final firmware.
This commit is contained in:
parent
2d3d2af051
commit
0824a2cd25
|
@ -0,0 +1,37 @@
|
|||
#include <sysinit.h>
|
||||
|
||||
#include "basic/basic.h"
|
||||
|
||||
#include "lcd/print.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
#include "final.gen"
|
||||
|
||||
static const struct MENU mainmenu = {"Menu", mentry};
|
||||
|
||||
void initNick();
|
||||
void fancyNickname();
|
||||
|
||||
void main_final(void) {
|
||||
//checkFirstBoot();
|
||||
|
||||
initNick();
|
||||
while(1){
|
||||
#ifndef FINAL
|
||||
if(getInputRaw()==BTN_LEFT)
|
||||
ISPandReset();
|
||||
#endif
|
||||
if(getInput()){
|
||||
handleMenu(&mainmenu);
|
||||
getInputWaitRelease();
|
||||
initNick();
|
||||
};
|
||||
fancyNickname();
|
||||
delayms_queue(100);
|
||||
};
|
||||
};
|
||||
|
||||
void tick_final(void);
|
|
@ -0,0 +1,126 @@
|
|||
#include <sysinit.h>
|
||||
|
||||
#include "basic/basic.h"
|
||||
#include "basic/config.h"
|
||||
|
||||
#include "lcd/print.h"
|
||||
#include "lcd/render.h"
|
||||
#include "lcd/display.h"
|
||||
|
||||
#include "filesystem/ff.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
void readcfg(void) {
|
||||
readConfig();
|
||||
};
|
||||
|
||||
void savecfg(void){
|
||||
saveConfig();
|
||||
};
|
||||
|
||||
void applycfg(void){
|
||||
applyConfig();
|
||||
};
|
||||
|
||||
void changer(void){
|
||||
uint8_t numentries = 0;
|
||||
signed char menuselection = 0;
|
||||
uint8_t visible_lines = 0;
|
||||
uint8_t current_offset = 0;
|
||||
|
||||
for (int i=0;the_config[i].name!=NULL;i++){
|
||||
numentries++;
|
||||
};
|
||||
|
||||
visible_lines = ((RESY/getFontHeight())-1)/2;
|
||||
|
||||
while (1) {
|
||||
// Display current menu page
|
||||
lcdClear();
|
||||
lcdPrint("Config");
|
||||
|
||||
lcdSetCrsrX(60);
|
||||
lcdPrint("[");
|
||||
lcdPrint(IntToStr(current_offset/visible_lines,1,0));
|
||||
lcdPrint("/");
|
||||
lcdPrint(IntToStr(numentries/visible_lines,1,0));
|
||||
lcdPrint("]");
|
||||
lcdNl();
|
||||
|
||||
lcdNl();
|
||||
|
||||
for (uint8_t i = current_offset; i < (visible_lines + current_offset) && i < numentries; i++) {
|
||||
if(i==0){
|
||||
lcdPrintln("Save changes:");
|
||||
if (i == menuselection)
|
||||
lcdPrint("*");
|
||||
lcdSetCrsrX(14);
|
||||
if (i == menuselection)
|
||||
lcdPrintln("YES");
|
||||
else
|
||||
lcdPrintln("no");
|
||||
}else{
|
||||
lcdPrintln(the_config[i].name);
|
||||
if (i == menuselection)
|
||||
lcdPrint("*");
|
||||
lcdSetCrsrX(14);
|
||||
lcdPrint("<");
|
||||
lcdPrint(IntToStr(the_config[i].value,3,F_LONG));
|
||||
lcdPrintln(">");
|
||||
};
|
||||
}
|
||||
lcdRefresh();
|
||||
|
||||
switch (getInputWait()) {
|
||||
case BTN_UP:
|
||||
menuselection--;
|
||||
if (menuselection < current_offset) {
|
||||
if (menuselection < 0) {
|
||||
menuselection = numentries-1;
|
||||
current_offset = ((numentries-1)/visible_lines) * visible_lines;
|
||||
} else {
|
||||
current_offset -= visible_lines;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BTN_DOWN:
|
||||
menuselection++;
|
||||
if (menuselection > (current_offset + visible_lines-1) || menuselection >= numentries) {
|
||||
if (menuselection >= numentries) {
|
||||
menuselection = 0;
|
||||
current_offset = 0;
|
||||
} else {
|
||||
current_offset += visible_lines;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BTN_LEFT:
|
||||
if(the_config[menuselection].value >
|
||||
the_config[menuselection].min)
|
||||
the_config[menuselection].value--;
|
||||
if(the_config[menuselection].value > the_config[menuselection].max)
|
||||
the_config[menuselection].value=
|
||||
the_config[menuselection].max;
|
||||
applyConfig();
|
||||
break;
|
||||
case BTN_RIGHT:
|
||||
if(the_config[menuselection].value <
|
||||
the_config[menuselection].max)
|
||||
the_config[menuselection].value++;
|
||||
if(the_config[menuselection].value < the_config[menuselection].min)
|
||||
the_config[menuselection].value=
|
||||
the_config[menuselection].min;
|
||||
applyConfig();
|
||||
break;
|
||||
case BTN_ENTER:
|
||||
if(menuselection==0)
|
||||
saveConfig();
|
||||
return;
|
||||
}
|
||||
getInputWaitRelease();
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
|
||||
flame m0dul - https://github.com/kiu/flame
|
||||
|
||||
*/
|
||||
|
||||
#include "basic/basic.h"
|
||||
#include "core/i2c/i2c.h"
|
||||
#include "basic/config.h"
|
||||
|
||||
#define FLAME_I2C_WRITE 0xC4
|
||||
#define FLAME_I2C_READ 0xC5
|
||||
|
||||
#define FLAME_I2C_CR_INPUT 0x00
|
||||
#define FLAME_I2C_CR_PSC0 0x01
|
||||
#define FLAME_I2C_CR_PWM0 0x02
|
||||
#define FLAME_I2C_CR_PSC1 0x03
|
||||
#define FLAME_I2C_CR_PWM1 0x04
|
||||
#define FLAME_I2C_CR_LS0 0x05
|
||||
|
||||
#define FLAME_I2C_LS0_OFF 0x00
|
||||
#define FLAME_I2C_LS0_ON 0x01
|
||||
#define FLAME_I2C_LS0_PWM0 0x02
|
||||
#define FLAME_I2C_LS0_PWM1 0x03
|
||||
|
||||
#define FLAME_I2C_LS0_LED0 0x00
|
||||
#define FLAME_I2C_LS0_LED1 0x02
|
||||
#define FLAME_I2C_LS0_LED2 0x04
|
||||
#define FLAME_I2C_LS0_LED3 0x06
|
||||
|
||||
#define FLAME_OFF 0x00
|
||||
#define FLAME_UP 0x01
|
||||
#define FLAME_UP_WAIT 0x02
|
||||
#define FLAME_DOWN 0x03
|
||||
#define FLAME_DOWN_WAIT 0x04
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
#define flameBrightnessMax GLOBAL(flamemax)
|
||||
#define flameBrightnessMin GLOBAL(flamemin)
|
||||
#define flameSpeedUp GLOBAL(flamespeed)
|
||||
#define flameSpeedDown GLOBAL(flamespeed)
|
||||
#define flameWaitUp GLOBAL(flamemaxw)
|
||||
#define flameWaitDown GLOBAL(flameminw)
|
||||
|
||||
uint8_t flameEnabled = 0;
|
||||
uint8_t flameMode = FLAME_OFF;
|
||||
uint8_t flameI2Cpwm = 0;
|
||||
uint8_t flameTicks = 0;
|
||||
|
||||
uint32_t flameSetI2C(uint8_t cr, uint8_t value) {
|
||||
I2CMasterBuffer[0] = FLAME_I2C_WRITE;
|
||||
I2CMasterBuffer[1] = cr;
|
||||
I2CMasterBuffer[2] = value;
|
||||
I2CWriteLength = 3;
|
||||
I2CReadLength = 0;
|
||||
return i2cEngine();
|
||||
}
|
||||
|
||||
void setFlamePWM() {
|
||||
flameSetI2C(FLAME_I2C_CR_PWM0, flameI2Cpwm); // set pwm
|
||||
}
|
||||
|
||||
|
||||
void tick_flame(void) { // every 10ms
|
||||
flameTicks++;
|
||||
|
||||
if (flameI2Cpwm > flameBrightnessMax) {
|
||||
flameI2Cpwm = flameBrightnessMax;
|
||||
}
|
||||
if (flameI2Cpwm < flameBrightnessMin) {
|
||||
flameI2Cpwm = flameBrightnessMin;
|
||||
}
|
||||
|
||||
if (flameMode == FLAME_OFF) {
|
||||
if (isNight() && flameEnabled) {
|
||||
flameTicks = 0;
|
||||
flameMode = FLAME_UP;
|
||||
}
|
||||
}
|
||||
|
||||
if (flameMode == FLAME_UP) {
|
||||
if (flameI2Cpwm + flameSpeedUp > flameI2Cpwm ) {
|
||||
flameI2Cpwm += flameSpeedUp;
|
||||
} else {
|
||||
flameI2Cpwm = 0xFF;
|
||||
}
|
||||
push_queue(&setFlamePWM);
|
||||
if (flameI2Cpwm == flameBrightnessMax) {
|
||||
flameMode = FLAME_UP_WAIT;
|
||||
flameTicks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (flameMode == FLAME_UP_WAIT) {
|
||||
if (flameTicks >= flameWaitUp) {
|
||||
flameMode = FLAME_DOWN;
|
||||
}
|
||||
}
|
||||
|
||||
if (flameMode == FLAME_DOWN) {
|
||||
if (flameI2Cpwm - flameSpeedDown < flameI2Cpwm ) {
|
||||
flameI2Cpwm -= flameSpeedDown;
|
||||
} else {
|
||||
flameI2Cpwm = 0x00;
|
||||
}
|
||||
push_queue(&setFlamePWM);
|
||||
if (flameI2Cpwm == flameBrightnessMin) {
|
||||
flameMode = FLAME_DOWN_WAIT;
|
||||
flameTicks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (flameMode == FLAME_DOWN_WAIT) {
|
||||
if (flameTicks >= flameWaitDown) {
|
||||
flameMode = FLAME_OFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void flameInit(void) {
|
||||
|
||||
i2cInit(I2CMASTER); // Init I2C
|
||||
|
||||
flameEnabled = (flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED0) == I2CSTATE_ACK); // probe i2c
|
||||
|
||||
if (flameEnabled) {
|
||||
flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED0); // set led0 off
|
||||
flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED1); // set led1 off
|
||||
flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED2); // set led2 off
|
||||
flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED3); // set led3 off
|
||||
|
||||
flameSetI2C(FLAME_I2C_CR_PSC0, 0x00); // set prescaler
|
||||
flameSetI2C(FLAME_I2C_CR_PWM0, 0x00); // set pwm
|
||||
flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_PWM0 << FLAME_I2C_LS0_LED0); // set led0 to pwm
|
||||
}
|
||||
}
|
|
@ -0,0 +1,286 @@
|
|||
#include <sysinit.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "basic/basic.h"
|
||||
#include "basic/byteorder.h"
|
||||
|
||||
#include "lcd/lcd.h"
|
||||
#include "lcd/print.h"
|
||||
|
||||
#include "funk/nrf24l01p.h"
|
||||
|
||||
#include "funk/mesh.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
void m_init(void){
|
||||
nrf_init();
|
||||
|
||||
struct NRF_CFG config = {
|
||||
.channel= MESH_CHANNEL,
|
||||
.txmac= MESH_MAC,
|
||||
.nrmacs=1,
|
||||
.mac0= MESH_MAC,
|
||||
.maclen ="\x20", // XXX: MESHPKTSIZE
|
||||
};
|
||||
|
||||
nrf_config_set(&config);
|
||||
|
||||
initMesh();
|
||||
};
|
||||
|
||||
void m_tset(void){
|
||||
_timet=1311961112;
|
||||
};
|
||||
|
||||
void m_time(void){
|
||||
struct tm* tm;
|
||||
char c[2]={0,0};
|
||||
getInputWaitRelease();
|
||||
delayms(100);
|
||||
do{
|
||||
lcdClear();
|
||||
tm= mygmtime(getSeconds());
|
||||
lcdPrint(IntToStr(tm->tm_hour,2,F_LONG));
|
||||
lcdPrint(":");
|
||||
lcdPrint(IntToStr(tm->tm_min,2,F_LONG|F_ZEROS));
|
||||
lcdPrint(":");
|
||||
lcdPrint(IntToStr(tm->tm_sec,2,F_LONG|F_ZEROS));
|
||||
lcdNl();
|
||||
lcdPrint(IntToStr(tm->tm_mday,2,F_LONG));
|
||||
lcdPrint(".");
|
||||
lcdPrint(IntToStr(tm->tm_mon+1,2,0));
|
||||
lcdPrint(".");
|
||||
lcdPrint(IntToStr(tm->tm_year+YEAR0,4,F_LONG|F_ZEROS));
|
||||
lcdNl();
|
||||
|
||||
lcdNl();
|
||||
lcdPrint("<");
|
||||
|
||||
for(int i=0;i<MESHBUFSIZE;i++){
|
||||
if(!meshbuffer[i].flags&MF_USED){
|
||||
c[0]='_';
|
||||
}else{
|
||||
c[0]=meshbuffer[i].pkt[0];
|
||||
};
|
||||
lcdPrint(c);
|
||||
};
|
||||
lcdPrintln(">");
|
||||
|
||||
lcdPrint("Gen:");
|
||||
lcdPrintInt(meshgen);
|
||||
lcdNl();
|
||||
lcdRefresh();
|
||||
delayms_queue(50);
|
||||
}while ((getInputRaw())==BTN_NONE);
|
||||
};
|
||||
|
||||
|
||||
inline void blink(char a, char b){
|
||||
gpioSetValue (a,b, 1-gpioGetValue(a,b));
|
||||
};
|
||||
|
||||
|
||||
int choose(char * texts, int8_t menuselection){
|
||||
uint8_t numentries = 0;
|
||||
uint8_t visible_lines = 0;
|
||||
uint8_t current_offset = 0;
|
||||
|
||||
char*p=texts;
|
||||
|
||||
do{
|
||||
lcdPrintln(p);
|
||||
while(*p)p++;
|
||||
numentries++;p++;
|
||||
}while(*p);
|
||||
numentries--;
|
||||
|
||||
visible_lines = (RESY/getFontHeight())-1; // subtract title line
|
||||
|
||||
while (1) {
|
||||
// Display current menu page
|
||||
lcdClear();
|
||||
lcdPrintln(texts);
|
||||
p=texts;
|
||||
while(*p++);
|
||||
for(int i=0;i<current_offset;i++)
|
||||
while(*p++);
|
||||
for (uint8_t i = current_offset; i < (visible_lines + current_offset) && i < numentries; i++) {
|
||||
if (i == menuselection)
|
||||
lcdPrint("*");
|
||||
lcdSetCrsrX(14);
|
||||
lcdPrintln(p);
|
||||
while(*p++);
|
||||
}
|
||||
lcdRefresh();
|
||||
|
||||
switch (getInputWait()) {
|
||||
case BTN_UP:
|
||||
menuselection--;
|
||||
if (menuselection < current_offset) {
|
||||
if (menuselection < 0) {
|
||||
menuselection = numentries-1;
|
||||
current_offset = ((numentries-1)/visible_lines) * visible_lines;
|
||||
} else {
|
||||
current_offset -= visible_lines;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BTN_DOWN:
|
||||
menuselection++;
|
||||
if (menuselection > (current_offset + visible_lines-1) || menuselection >= numentries) {
|
||||
if (menuselection >= numentries) {
|
||||
menuselection = 0;
|
||||
current_offset = 0;
|
||||
} else {
|
||||
current_offset += visible_lines;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BTN_LEFT:
|
||||
return -1;
|
||||
case BTN_RIGHT:
|
||||
case BTN_ENTER:
|
||||
return menuselection;
|
||||
}
|
||||
getInputWaitRelease();
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
char *meshmsgs(void){
|
||||
static char msgtypes[MESHBUFSIZE+1];
|
||||
memset(msgtypes,'_',MESHBUFSIZE);
|
||||
msgtypes[MESHBUFSIZE]=0;
|
||||
uint8_t lo=0;
|
||||
uint8_t hi;
|
||||
|
||||
for(int o=0;o<MESHBUFSIZE;o++){
|
||||
hi=0xff;
|
||||
for(int i=0;i<MESHBUFSIZE;i++){
|
||||
if(meshbuffer[i].flags&MF_USED){
|
||||
if(MO_TYPE(meshbuffer[i].pkt)>lo)
|
||||
if(MO_TYPE(meshbuffer[i].pkt)<hi)
|
||||
hi=MO_TYPE(meshbuffer[i].pkt);
|
||||
};
|
||||
};
|
||||
if(hi==0xff){
|
||||
msgtypes[o]=0;
|
||||
break;
|
||||
};
|
||||
msgtypes[o]=hi;
|
||||
lo=hi;
|
||||
};
|
||||
|
||||
return msgtypes;
|
||||
};
|
||||
|
||||
|
||||
|
||||
extern MPKT meshbuffer[MESHBUFSIZE];
|
||||
void m_choose(){
|
||||
char list[99];
|
||||
int i=0;
|
||||
|
||||
while(1){
|
||||
char *p=list;
|
||||
strcpy(p,"Note");
|
||||
while(*p++);
|
||||
|
||||
char *mm=meshmsgs();
|
||||
char *tmm=mm;
|
||||
while(*mm){
|
||||
switch(*mm){
|
||||
case('A'):
|
||||
strcpy(p,"Message");
|
||||
break;
|
||||
case('E'):
|
||||
strcpy(p,"Kourou");
|
||||
break;
|
||||
case('F'):
|
||||
strcpy(p,"Baikonur");
|
||||
break;
|
||||
case('T'):
|
||||
strcpy(p,"Time");
|
||||
break;
|
||||
case('i'):
|
||||
strcpy(p,"Invaders");
|
||||
break;
|
||||
default:
|
||||
p[0]=*mm;
|
||||
p[1]=0;
|
||||
};
|
||||
while(*p++);
|
||||
mm++;
|
||||
};
|
||||
p[0]=0;
|
||||
|
||||
i=choose(list,i);
|
||||
if(i<0)
|
||||
return;
|
||||
lcdClear();
|
||||
|
||||
int j=0;
|
||||
for(int z=0;z<MESHBUFSIZE;z++)
|
||||
if(meshbuffer[z].flags&MF_USED)
|
||||
if(MO_TYPE(meshbuffer[z].pkt)==tmm[i])
|
||||
j=z;
|
||||
|
||||
switch(tmm[i]){
|
||||
case('A'):
|
||||
lcdPrintln("Message");
|
||||
break;
|
||||
case('E'):
|
||||
lcdPrintln("Kourou");
|
||||
break;
|
||||
case('F'):
|
||||
lcdPrintln("Baikonur");
|
||||
break;
|
||||
case('T'):
|
||||
lcdPrintln("Time");
|
||||
break;
|
||||
case('i'):
|
||||
lcdPrintln("Invaders");
|
||||
break;
|
||||
};
|
||||
if(tmm[i]>='a' && tmm[i]<='z'){
|
||||
lcdPrintln(IntToStr(MO_TIME(meshbuffer[j].pkt),10,0));
|
||||
}else{
|
||||
struct tm *tm= mygmtime(MO_TIME(meshbuffer[j].pkt));
|
||||
lcdPrint(IntToStr(tm->tm_hour,2,F_LONG));
|
||||
lcdPrint(":");
|
||||
lcdPrint(IntToStr(tm->tm_min,2,F_LONG|F_ZEROS));
|
||||
lcdPrint(":");
|
||||
lcdPrint(IntToStr(tm->tm_sec,2,F_LONG|F_ZEROS));
|
||||
lcdNl();
|
||||
};
|
||||
char *foo=(char *)MO_BODY(meshbuffer[j].pkt);
|
||||
while(strlen(foo)>13){
|
||||
int q;
|
||||
for(q=0;q<13;q++){
|
||||
if(foo[q]==' ')
|
||||
break;
|
||||
};
|
||||
foo[q]=0;
|
||||
lcdPrintln(foo);
|
||||
foo[q]=' ';
|
||||
foo+=q+1;
|
||||
};
|
||||
lcdPrintln(foo);
|
||||
lcdRefresh();
|
||||
getInputWaitRelease();
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
void tick_mesh(void){
|
||||
mesh_systick();
|
||||
};
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
#include <sysinit.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "basic/basic.h"
|
||||
#include "basic/byteorder.h"
|
||||
#include "basic/config.h"
|
||||
|
||||
#include "lcd/lcd.h"
|
||||
#include "lcd/print.h"
|
||||
|
||||
#include "filesystem/ff.h"
|
||||
#include "filesystem/select.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
void fancyNickname(void) {
|
||||
int dx=0;
|
||||
int dy=0;
|
||||
static uint32_t ctr=0;
|
||||
ctr++;
|
||||
|
||||
|
||||
lcdClear();
|
||||
setExtFont(GLOBAL(nickfont));
|
||||
DoString(dx,dy,GLOBAL(nickname));
|
||||
lcdRefresh();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
void initNick(void){
|
||||
readFile("nick.cfg",GLOBAL(nickname),MAXNICK);
|
||||
// readFile("font.cfg",GLOBAL(nickfont),FILENAMELEN);
|
||||
};
|
||||
|
||||
void doNick(void){
|
||||
input("Nickname:", GLOBAL(nickname), 32, 127, MAXNICK-1);
|
||||
writeFile("nick.cfg",GLOBAL(nickname),strlen(GLOBAL(nickname)));
|
||||
getInputWait();
|
||||
};
|
||||
|
||||
void doFont(void){
|
||||
getInputWaitRelease();
|
||||
if( selectFile(GLOBAL(nickfont),"F0N") != 0){
|
||||
lcdPrintln("No file selected.");
|
||||
return;
|
||||
};
|
||||
|
||||
lcdClear();
|
||||
lcdPrintln(GLOBAL(nickfont));
|
||||
setExtFont(GLOBAL(nickfont));
|
||||
lcdPrintln("PUabc€");
|
||||
setIntFont(&Font_7x8);
|
||||
lcdPrintln("done.");
|
||||
lcdDisplay();
|
||||
while(!getInputRaw())delayms(10);
|
||||
};
|
||||
|
||||
|
||||
#if 0
|
||||
void f_font(void){
|
||||
|
||||
if( selectFile(fontname,"F0N") != 0){
|
||||
lcdPrintln("No file selected.");
|
||||
return;
|
||||
};
|
||||
|
||||
lcdClear();
|
||||
lcdPrintln(fontname);
|
||||
setExtFont(fontname);
|
||||
lcdPrintln("PUabc€");
|
||||
setIntFont(&Font_7x8);
|
||||
lcdPrintln("done.");
|
||||
lcdDisplay();
|
||||
while(!getInputRaw())delayms(10);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,129 @@
|
|||
#include <sysinit.h>
|
||||
|
||||
#include "basic/basic.h"
|
||||
#include "basic/config.h"
|
||||
|
||||
#include "lcd/lcd.h"
|
||||
#include "lcd/print.h"
|
||||
#include "lcd/allfonts.h"
|
||||
|
||||
#include "filesystem/ff.h"
|
||||
#include "filesystem/select.h"
|
||||
#include "funk/nrf24l01p.h"
|
||||
#include "usb/usbmsc.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
void show_ticks(void) {
|
||||
int dx=0;
|
||||
int dy=8;
|
||||
lcdClear();
|
||||
dx=DoString(0,dy,"Ticks:");
|
||||
while ((getInputRaw())==BTN_NONE){
|
||||
DoInt(0,dy+8,_timectr);
|
||||
lcdDisplay();
|
||||
};
|
||||
dy+=16;
|
||||
dx=DoString(0,dy,"Done.");
|
||||
};
|
||||
|
||||
|
||||
void chrg_stat(void) {
|
||||
int stat;
|
||||
while ((getInputRaw())==BTN_NONE){
|
||||
lcdClear();
|
||||
lcdPrintln("Chrg_stat:");
|
||||
stat=gpioGetValue(RB_PWR_CHRG);
|
||||
lcdPrint(IntToStr(stat,3,0));
|
||||
lcdNl();
|
||||
lcdRefresh();
|
||||
};
|
||||
lcdPrintln("Done.");
|
||||
};
|
||||
void adc_light(void) {
|
||||
int dx=0;
|
||||
int dy=8;
|
||||
dx=DoString(0,dy,"Light:");
|
||||
DoString(0,dy+16,"Night:");
|
||||
while ((getInputRaw())==BTN_NONE){
|
||||
DoInt(dx,dy,GetLight());
|
||||
DoInt(dx,dy+16,isNight());
|
||||
DoInt(dx,dy+8,GLOBAL(daytrig));
|
||||
lcdDisplay();
|
||||
};
|
||||
dy+=8;
|
||||
dx=DoString(0,dy,"Done.");
|
||||
};
|
||||
|
||||
void uptime(void) {
|
||||
int t;
|
||||
int h;
|
||||
char flag;
|
||||
while ((getInputRaw())==BTN_NONE){
|
||||
lcdClear();
|
||||
lcdPrintln("Uptime:");
|
||||
t=getTimer()/(1000/SYSTICKSPEED);
|
||||
h=t/60/60;
|
||||
flag=F_ZEROS;
|
||||
if(h>0){
|
||||
lcdPrint(IntToStr(h,2,flag));
|
||||
lcdPrint("h");
|
||||
flag|=F_LONG;
|
||||
};
|
||||
h=t/60%60;
|
||||
if(h>0){
|
||||
lcdPrint(IntToStr(h,2,flag));
|
||||
lcdPrint("m");
|
||||
flag|=F_LONG;
|
||||
};
|
||||
h=t%60;
|
||||
if(h>0){
|
||||
lcdPrint(IntToStr(h,2,flag));
|
||||
lcdPrint("s");
|
||||
};
|
||||
lcdNl();
|
||||
lcdRefresh();
|
||||
delayms_queue(200);
|
||||
};
|
||||
lcdPrintln("done.");
|
||||
};
|
||||
|
||||
void gotoISP(void) {
|
||||
DoString(0,0,"Enter ISP!");
|
||||
lcdDisplay();
|
||||
ISPandReset();
|
||||
}
|
||||
|
||||
void lcd_mirror(void) {
|
||||
lcdToggleFlag(LCD_MIRRORX);
|
||||
};
|
||||
|
||||
void lcd_invert(void) {
|
||||
lcdToggleFlag(LCD_INVERTED);
|
||||
};
|
||||
|
||||
void adc_check(void) {
|
||||
int dx=0;
|
||||
int dy=8;
|
||||
// Print Voltage
|
||||
dx=DoString(0,dy,"Voltage:");
|
||||
while ((getInputRaw())==BTN_NONE){
|
||||
DoInt(dx,dy,GetVoltage());
|
||||
lcdDisplay();
|
||||
};
|
||||
dy+=8;
|
||||
dx=DoString(0,dy,"Done.");
|
||||
};
|
||||
|
||||
void msc_menu(void){
|
||||
DoString(0,8,"MSC Enabled.");
|
||||
lcdDisplay();
|
||||
usbMSCInit();
|
||||
getInputWaitRelease();
|
||||
getInputWait();
|
||||
DoString(0,16,"MSC Disabled.");
|
||||
usbMSCOff();
|
||||
fsReInit();
|
||||
};
|
|
@ -0,0 +1,26 @@
|
|||
#include <sysinit.h>
|
||||
|
||||
#include "basic/basic.h"
|
||||
|
||||
#include "lcd/lcd.h"
|
||||
#include "lcd/print.h"
|
||||
|
||||
#include "funk/nrf24l01p.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "funk/rftransfer.h"
|
||||
#include "funk/openbeacon.h"
|
||||
|
||||
#include "core/iap/iap.h"
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
void f_uuid(void) {
|
||||
IAP_return_t iap_return;
|
||||
iap_return = iapReadSerialNumber();
|
||||
lcdPrintIntHex(iap_return.Result[0]); lcdNl();
|
||||
lcdPrintIntHex(iap_return.Result[1]); lcdNl();
|
||||
lcdPrintIntHex(iap_return.Result[2]); lcdNl();
|
||||
lcdPrintIntHex(iap_return.Result[3]); lcdNl();
|
||||
}
|
Loading…
Reference in New Issue