Example #1
0
//# MENU rgb_leds
void selectLedFile(void){
    if(GLOBAL(rgbleds)) {
        if(init_selectFile("L3D")){
            while(selectFileRepeat(GLOBAL(ledfile),"L3D") >= 0) {
                writeFile("ledfile.cfg", GLOBAL(ledfile), strlen(GLOBAL(ledfile)));
                init_rgbLeds();
            }
        }
    } else {
        lcdClear();
        lcdNl();
        lcdPrintln("You need to enable");
        lcdPrintln("<rgbleds> in the");
        lcdPrintln("config to use");
        lcdPrintln("this!");
        lcdNl();
        lcdPrintln(" LEFT: back");
        lcdPrintln(" ENTER/RIGHT:");
        lcdPrintln("       open config");
        lcdDisplay();

        while(1){
            switch(getInput()){
                case BTN_LEFT:
                    return;
                case BTN_RIGHT:
                case BTN_ENTER:
                    menu_config();
                    return;
            }
        }
    }
}
Example #2
0
//# MENU cpld
void cpld_menu(){
	getInputWaitRelease();
	SETUPgout(EN_1V8);
	ON(EN_1V8);
	delayNop(1000000); /* wait until cpld boot */
	cpu_clock_set(204);

	lcdClear();
	lcdPrintln("CPLD");
	lcdNl();
	lcdNl();
	bytes=0;
	lcdPrint(IntToStr(bytes,5,F_LONG));
	lcdPrint(" bytes...");
	lcdNl();

	#define WAIT_LOOP_DELAY (6000000)
	#define ALL_LEDS  (PIN_LED1|PIN_LED2|PIN_LED3)
	int i;
	int error;
	FRESULT res;

	res=f_open(&file, "cpld.xsv", FA_OPEN_EXISTING|FA_READ);
	if(res!=FR_OK){
	    lcdPrintln("FOPEN ERROR");
	    lcdPrintln(f_get_rc_string(res));
	    lcdDisplay();
	    getInputWait();
	    return;
	};
	refill_cpld_buffer_fs();

	error = cpld_jtag_program(sizeof(cpld_xsvf_buffer),
				  cpld_xsvf_buffer,
				  refill_cpld_buffer_fs);
	if(error){
	    lcdPrintln("Programming failed!");
	    lcdPrintln(IntToStr(error,5,0));
	    lcdDisplay();
	    /* LED3 (Red) steady on error */
	    ON(LED3);
	    while (1);
	};


	lcdPrintln("Success.");
	lcdDisplay();

	for (res=0;res<10;res++){
	    /* blink LED1, LED2, and LED3 on success */
	    TOGGLE(LED1);
	    TOGGLE(LED2);
	    TOGGLE(LED3);
	    for (i = 0; i < WAIT_LOOP_DELAY; i++)  /* Wait a bit. */
		__asm__("nop");
	};
	/* XXX: Maybe power toggle needed to start CPLD? */
	OFF(EN_1V8);
};
Example #3
0
void board_menu_draw(board_t* b)
{
  setTextColor(0, 0xff);
  setIntFont(&Font_7x8);

  const int lineh = getFontHeight();

  lcdSetCrsr(0, 0);
  lcdPrintln("0xb number game");
  lcdPrintln("Push < > ^ v");
  lcdPrintln("Add same blocks");
  lcdPrint("Try to reach '");
  setTextColor(colors[N_COLORS-1].bg, colors[N_COLORS-1].fg);
  lcdPrint("b");
  setTextColor(0, 0xff);
  lcdPrintln("'!");
  lcdNl();

  for (uint i = 0; i < menu_N; i ++) {
    if (i == b->menu_item)
      lcdPrint(">> ");
    else
      lcdPrint("   ");
    lcdPrint(menu_str[i]);

    switch (i) {
      case 3:
        // width
        lcdPrint(" = ");
        lcdPrint(IntToStr(b->w, 2, 0));
        break;
      case 4:
        // height
        lcdPrint(" = ");
        lcdPrint(IntToStr(b->h, 2, 0));
      default:
        break;
    }
    lcdNl();
  }

  if (b->menu_item == 2) {
    lcdPrintln(font_list[b->font]);
    if (b->font == FONT_NONE) {
      uint w = RESX / N_COLORS;
      for (uint8_t i = 0; i < N_COLORS; i++) {
        const color_t* col = colors + i;
        setTextColor(col->bg, col->fg);
        DoRect(i*w, 120, w, 10);
      }
    }
    else {
      setExtFont(font_list[b->font]);
      lcdPrint("789ab");
    }
  }
}
Example #4
0
void ram(void){
  if (lcdShowImageFile("nick.lcd") != 0) {
    lcdClear();
    lcdNl();
    lcdPrintln("File nick.lcd");
    lcdPrintln("not present.");
    lcdNl();
    lcdDisplay();
  }
}
Example #5
0
void drawUsage(double usage)
{
	int lineHeight = getFontHeight();
	int y1 = lcdGetCrsrY();
	int y2 = y1 + lineHeight;
	static const int frameSize = 1;
	BYTE color_frame = 0x00;

	// Colors: green - yellow - red
	static const BYTE colors[] = {
		0x1C, 0x3C, 0x5C, 0x7C, 0x9C, 0xBC, 0xDC, 0xFC,
		0xF8, 0xF4, 0xF0, 0xEC, 0xE8, 0xE4, 0xE0
	};

	drawRectFill(0, y1+frameSize, frameSize, lineHeight-2*frameSize, color_frame);
	drawRectFill(0, y1, 3*frameSize, frameSize, color_frame);
	drawRectFill(0, y2-frameSize, 3*frameSize, frameSize, color_frame);

	drawRectFill(RESX-frameSize, y1+frameSize, frameSize, lineHeight-2*frameSize, color_frame);
	drawRectFill(RESX-3*frameSize, y1, 3*frameSize, frameSize, color_frame);
	drawRectFill(RESX-3*frameSize, y2-frameSize, 3*frameSize, frameSize, color_frame);

	int lines = (RESX - 2*frameSize - 1) * usage + 0.5;
	for(int i = 0; i < lines; ++i)
		drawVLine(frameSize + i, y1 + frameSize, y2 - frameSize - 1, colors[(int)((double)i / (RESX-2*frameSize) * sizeof(colors) + 0.5)]);

	lcdNl();
}
Example #6
0
int main(void) {
    cpu_clock_init(); /* CPU Clock is now 104 MHz */
    ssp_clock_init();
    systickInit();

    SETUPgout(EN_VDD);
    SETUPgout(MIXER_EN);
    SETUPgout(MIC_AMP_DIS);

    SETUPgout(LED1);
    SETUPgout(LED2);
    SETUPgout(LED3);
    SETUPgout(LED4);

    inputInit();
    lcdInit();
    lcdFill(0xff);
    lcdPrintln("Flash-App");
    lcdNl();
    lcdDisplay();

    cpld_flash();
    cpu_clock_set(50);
    full_msc();

    return 0;
}
Example #7
0
//# MENU cpld
void cpld_flash() {
    SETUPgout(EN_1V8);
    ON(EN_1V8);
    delay(1000000); /* wait until cpld boot */
    cpu_clock_set(204);

    lcdPrintln("Program CPLD");
    bytes=0;
    lcdPrint(IntToStr(bytes,5,F_LONG));
    lcdPrint(" bytes...");
    lcdNl();

#define WAIT_LOOP_DELAY (6000000)
#define ALL_LEDS  (PIN_LED1|PIN_LED2|PIN_LED3)
    int i;
    int error;

    refill_cpld_buffer_fs();

    error = cpld_jtag_program(sizeof(cpld_xsvf_buffer),
                              cpld_xsvf_buffer,
                              refill_cpld_buffer_fs);
    if(error) {
        lcdPrintln("Programming failed!");
        lcdPrintln(IntToStr(error,5,0));
        lcdDisplay();
        /* LED3 (Red) steady on error */
        ON(LED4);
        while (1);
    };

    lcdPrintln("Success.");
    lcdDisplay();
    OFF(EN_1V8);
};
Example #8
0
void doInfo(){
	lcdClear(0xff);
	lcdNl();
	lcdPrint("PC:      "); lcdPrint(IntToStr(get_pc(),8,F_HEX));lcdNl();
	lcdPrint("StackP:  "); lcdPrint(IntToStr(get_sp(),8,F_HEX));lcdNl();
	lcdPrint("ShadowR: "); lcdPrint(IntToStr(CREG_M4MEMMAP,8,F_HEX));lcdNl();
	lcdPrint("text_s:  "); lcdPrint(IntToStr((uintptr_t)&_text_start,8,F_HEX));lcdNl();
	lcdPrint("bin_end: "); lcdPrint(IntToStr((uintptr_t)&_bin_end,8,F_HEX));lcdNl();
	lcdPrint("bin_size:"); lcdPrint(IntToStr((uintptr_t)&_bin_size,8,F_HEX));lcdNl();
	lcdPrint("reloc_ep:"); lcdPrint(IntToStr((uintptr_t)&_reloc_ep,8,F_HEX));lcdNl();
	lcdPrint("end:     "); lcdPrint(IntToStr((uintptr_t)&_end,8,F_HEX));lcdNl();
	lcdPrint("startloc:"); lcdPrint(IntToStr(sli,8,F_HEX));lcdNl();
	lcdDisplay();

	getInputWait();
};
Example #9
0
void doFlash(){
	uint32_t addr = 0;
	uint16_t len   = (uintptr_t)&_bin_size;
	uint8_t * data = (uint8_t *)&_reloc_ep;
	lcdPrintln("Flashing");
	lcdPrint(IntToStr(len,6,0));
	lcdPrintln(" bytes");
	lcdDisplay();
	flash_random_write(addr, len, data);
	lcdPrintln("done.");
	lcdDisplay();
	flash_read(addr, len, &_app_start);
	uint16_t idx;
	int err=0;
	for (idx=0;idx<len;idx++){
		if ((&_app_start)[idx] != data[idx]){
			lcdPrint(IntToStr(idx,4,F_HEX));
			lcdPrint(": ");
			lcdPrint(IntToStr((&_app_start)[idx],2,F_HEX));
			lcdPrint("!=");
			lcdPrint(IntToStr(data[idx],2,F_HEX));
			lcdNl();
			err++;
			lcdDisplay();
		};
		if(err%4==1){
			getInputWait();
		};
	};

	getInputWait();
};
Example #10
0
void printDisk()
{
	FATFS fs;
	FS_USAGE fs_usage;

	fsInfo(&fs);
	lcdPrintln("[Disk]");
	lcdNl();

	lcdPrint("format: ");
	switch(fs.fs_type)
	{
		case 0:
			lcdPrintln("unmounted");
			break;

		case FS_FAT12:
			lcdPrintln("FAT12");
			break;
		case FS_FAT16:
			lcdPrintln("FAT16");
			break;
		case FS_FAT32:
			lcdPrintln("FAT32");
			break;

		default:
			lcdPrint("Unknown: ");
			lcdPrintln(IntToStr(fs.fs_type,3,0));
			break;
	}

	fsUsage(&fs, &fs_usage);
	lcdPrint("total: ");
	prettyPrintSize(fs_usage.total);
	lcdNl();
	lcdPrint("free:  ");
	prettyPrintSize(fs_usage.free);
	lcdNl();
	lcdNl();

	double usage = 1 - ((double)fs_usage.free / fs_usage.total);
	lcdPrint("usage: ");
	lcdPrint(IntToStr(usage*100,3,0));
	lcdPrintln("%");
	drawUsage(usage);
}
Example #11
0
static void refill_cpld_buffer_fs(void) {
    memcpy(cpld_xsvf_buffer,default_xsvf+bytes,BLOCK);

    lcdMoveCrsr(0,-8);
    bytes+=BLOCK;
    lcdPrint(IntToStr(bytes,5,F_LONG)); lcdPrint(" bytes..."); lcdNl();
    lcdDisplay();
}
Example #12
0
File: funk.c Project: Bediko/r0ket
void f_send(void){
    uint8_t status;

    status = openbeaconSend();
    lcdPrint("Status:");
    lcdPrintCharHex(status);
    lcdNl();
};
Example #13
0
uint8_t check_end(void){
	if(player1.score >= MAX_POINTS || player2.score >= MAX_POINTS){
		receive = 0;
		lcdClear();
		lcdNl();
		lcdPrintln("  GAME OVER");
		lcdNl();
		lcdPrint(" Player ");
		lcdPrint(IntToStr(2 - (player1.score > player2.score),1,0));
		lcdPrintln(" won");

		lcdRefresh();

		return 1;
	}

	return 0;
}
Example #14
0
void printHeader()
{
	int lineHeight = getFontHeight();
	BYTE color = 0x00;

	lcdMoveCrsr(3, 2);
	lcdPrintln("System Information");
	lcdMoveCrsr(0, -2);
	drawHLine(lineHeight+3, 0, RESX-1, color);
	lcdNl();
}
Example #15
0
void full_msc(){
	MSCenable();
	lcdPrintln("FLASHMSC enabled.");
	lcdNl();
	lcdNl();
	lcdDisplay();
	while(getInputRaw()!=BTN_ENTER){
        uint32_t min = mscDisk_minAddressWR();
        uint32_t max = mscDisk_maxAddressWR();
        lcdMoveCrsr(0,-16);
        lcdPrint("MIN:");
        lcdPrintln(IntToStr(min,8,F_SSPACE));
        lcdPrint("MAX:");
        lcdPrintln(IntToStr(max,8,F_SSPACE));
        lcdDisplay();
        if(min == 0 && max == 2097151) {
            break;
        }
	};
	lcdPrintln("FLASHMSC disabled");
	lcdDisplay();
	MSCdisable();
};
Example #16
0
//# MENU led
void led_menu(){
	getInputWaitRelease();

	uint8_t leds=0;
	uint8_t adc=0;
	while(1){
		lcdClear();
		lcdPrintln("LED:");
		lcdPrintln("");
		lcdPrintln("U Toggle LEDs");
		lcdPrintln("D Toggle ADC");
		lcdPrintln("");
		lcdDisplay();
		switch(getInput()){
			case BTN_UP:
				adc=0;
				leds=1-leds;
				SETUPgout(LED4);
				if(leds){
					ON(LED1);
					ON(LED2);
					ON(LED3);
					ON(LED4);
				}else{
					OFF(LED1);
					OFF(LED2);
					OFF(LED3);
					OFF(LED4);
				};
				break;
			case BTN_DOWN:
				adc=1;
				SETUPadc(LED4);
				break;
			case BTN_ENTER:
				SETUPgout(LED1);
				SETUPgout(LED2);
				SETUPgout(LED3);
				SETUPgout(LED4);
				return;
		};
		if(adc){
			lcdPrint("LED4: ");
			lcdPrint(IntToStr(adc_get_single(ADC0,ADC_CR_CH6)*2*330/1023,4,F_LONG));
			lcdNl();
			lcdDisplay();
		};
		getInputWaitRelease();
	};
};
Example #17
0
static void refill_cpld_buffer_fs(void) {
    FRESULT res;
    UINT readbytes;

    res=f_read(&file, cpld_xsvf_buffer, BLOCK, &readbytes); 
    lcdMoveCrsr(0,-8);
    bytes+=readbytes;
    lcdPrint(IntToStr(bytes,5,F_LONG));
    lcdPrint(" bytes...");
    if (res!=FR_OK){
	    lcdPrintln(f_get_rc_string(res));
    };
    lcdNl();
    lcdDisplay();
}
Example #18
0
File: pwgen.c Project: Bediko/r0ket
void ram(void)
{
	char pw[PW_LEN+1];
	uint16_t k[8];
	int button;
	memset(k, 0, 16);
	while(1){
		lcdClear();
		lcdNl();
		lcdPrintln(" password");
		lcdPrintln("    generator");
		lcdNl();
		lcdNl();
		pw_set(pw,k);
		pw_cleanup(pw);
		lcdPrint("   ");
		lcdPrintln(pw);
		lcdRefresh();
		delayms(23);
		while((button=getInputRaw())==BTN_NONE)
			delayms(23);
		if(button==BTN_LEFT) return;
	}
}
Example #19
0
//# MENU antenna
void antenna_main()
{
	frequency=(int64_t)input_int("Frequency:",(int)(frequency/1000000),50,4000,4)*1000000;

	lcdClear();
	lcdSetCrsr(0,0);
	lcdPrintln("Antenna Frequency");

	lcdNl();
	lcdPrint(" ");
	lcdPrint(IntToStr(frequency/1000000,4,F_LONG));
	lcdPrintln(" MHz ");

	lcdNl();
	lcdPrintln("Antenna Length");

	float meter = SPEEDOFLIGHT/frequency;

	lcdNl();
	lcdPrint(" ");
	lcdPrint(IntToStr(meter * 1000, 4, F_LONG ));
	lcdPrint(" mm");
	lcdNl();
	lcdPrint(" ");
	lcdPrint(IntToStr(meter * 1000 / 2, 4, F_LONG ));
	lcdPrint(" mm");
	lcdNl();
	lcdPrint(" ");
	lcdPrint(IntToStr(meter * 1000 / 4, 4, F_LONG ));
	lcdPrint(" mm");

	lcdDisplay();

	getInputWaitRepeat();

}
Example #20
0
File: util.c Project: Bediko/r0ket
// //# MENU lcdread
void lcdrtest(void){
    lcdClear();
    lcdPrint("ID1:"); lcdPrintInt(lcdRead(128+64+16+8  +2  )); lcdNl();
    lcdPrint("ID2:"); lcdPrintInt(lcdRead(128+64+16+8  +2+1)); lcdNl();
    lcdPrint("ID3:"); lcdPrintInt(lcdRead(128+64+16+8+4    )); lcdNl();
    lcdPrint("ID4:"); lcdPrintInt(lcdRead(128+64+16+8+4  +1)); lcdNl();
    lcdPrint("Tmp:"); lcdPrintInt(lcdRead(128+64+16+8+4+2  )); lcdNl(); 
    lcdPrint("VM:"); lcdPrintInt(lcdRead(128+64+16+8+4+2+1)); lcdNl(); 
//    lcd_select(); mylcdWrite(0,128+32+8+4+1); lcd_deselect();
    delayms(10);
    lcdInit();
    lcdRefresh();
    while(!getInputRaw())delayms(10);
};
Example #21
0
File: funk.c Project: Bediko/r0ket
void f_cfg(void){
    struct NRF_CFG config;

    nrfconfig cfg=&config;

    nrf_config_get(cfg);

    lcdPrint("ch:");lcdPrintInt( cfg->channel ); lcdNl();
    lcdPrint("nr:");lcdPrintInt( cfg->nrmacs ); lcdNl();

    lcdPrint("0:");
    lcdPrintCharHex(cfg->mac0[0]);
    lcdPrintCharHex(cfg->mac0[1]);
    lcdPrintCharHex(cfg->mac0[2]);
    lcdPrintCharHex(cfg->mac0[3]);
    lcdPrintCharHex(cfg->mac0[4]);
    lcdNl();
    lcdPrint("1:");
    lcdPrintCharHex(cfg->mac1[0]);
    lcdPrintCharHex(cfg->mac1[1]);
    lcdPrintCharHex(cfg->mac1[2]);
    lcdPrintCharHex(cfg->mac1[3]);
    lcdPrintCharHex(cfg->mac1[4]);
    lcdNl();
    lcdPrint("2345:");
    lcdPrintCharHex(cfg->mac2345[0]);
    lcdPrintCharHex(cfg->mac2345[1]);
    lcdPrintCharHex(cfg->mac2345[2]);
    lcdPrintCharHex(cfg->mac2345[3]);
    lcdNl();
    lcdPrint("tx:");
    lcdPrintCharHex(cfg->txmac[0]);
    lcdPrintCharHex(cfg->txmac[1]);
    lcdPrintCharHex(cfg->txmac[2]);
    lcdPrintCharHex(cfg->txmac[3]);
    lcdPrintCharHex(cfg->txmac[4]);
    lcdNl();
    lcdPrint("len:");
    lcdPrintCharHex(cfg->maclen[0]);
    lcdPrintCharHex(cfg->maclen[1]);
    lcdPrintCharHex(cfg->maclen[2]);
    lcdPrintCharHex(cfg->maclen[3]);
    lcdPrintCharHex(cfg->maclen[4]);
    lcdNl();
};
Example #22
0
void doLCD(){

	uint8_t pwm=50;
	lcdClear(0xff);
	lcdPrintln("LCD-Test v1");
	lcdDisplay(); 
// #define LCD_BL_EN   P1_1,  SCU_CONF_FUNCTION1, GPIO0, GPIOPIN8 // LCD Backlight: PWM

	while(1){

		OFF(LCD_BL_EN);
		delayNop(10000+pwm*100);
		ON(LCD_BL_EN);
		delayNop(10000-pwm*100);

		switch(getInput()){
			case BTN_NONE:
				continue;
			case BTN_UP:
				break;
			case BTN_DOWN:
				break;
			case BTN_LEFT:
				pwm--;
				break;
			case BTN_RIGHT:
				pwm++;
				break;
			case BTN_ENTER:
				return;
				break;
		};
		lcdClear(0xff);
		lcdPrintln("LCD-Test v1");
		lcdPrintln("");
		lcdPrint("pwm=");lcdPrint(IntToStr(pwm,3,0));lcdNl();
		lcdDisplay(); 
	};
};
Example #23
0
void drawCommonThings(int charging) {
    lcdClear();
    lcdNl();
    lcdPrintln("  Battery status");

    // Draw battery frame.
    drawHLine(63,  14, 112,  0b00000011);
    drawHLine(93,  14, 112,  0b00000011);
    drawVLine(14,  63,  93,  0b00000011);
    drawVLine(112, 63,  73,  0b00000011);
    drawVLine(112, 83,  93,  0b00000011);
    drawHLine(73,  112, 116, 0b00000011);
    drawHLine(83,  112, 116, 0b00000011);
    drawVLine(116, 73,  83,  0b00000011);

    // Print if not charging.
    lcdSetCrsr(0, 40);
    if(!charging){
        lcdPrintln("  (not charging)");
    };
    lcdSetCrsr(0, 30);
}
Example #24
0
File: funk.c Project: Bediko/r0ket
void f_recv(void){
    __attribute__ ((aligned (4))) uint8_t buf[32];
    int len;
    do{

        lcdClear();
        len=nrf_rcv_pkt_time_encr(1000,sizeof(buf),buf,enctoggle?testkey:NULL);

        if(len==0){
            lcdPrintln("No pkt (Timeout)");
        };
        lcdPrint("Size:");lcdPrintInt(len);lcdNl();
        lcdPrint("1:");lcdPrintIntHex( *(int*)(buf+ 0) ); lcdNl();
        lcdPrint("2:");lcdPrintIntHex( *(int*)(buf+ 4) ); lcdNl();
        lcdPrint("3:");lcdPrintIntHex( *(int*)(buf+ 8) ); lcdNl();
        lcdPrint("4:");lcdPrintIntHex( *(int*)(buf+12) ); lcdNl();

        len=crc16(buf,14);
        lcdPrint("crc:");lcdPrintShortHex(len); lcdNl();
        lcdDisplay();
    }while ((getInputRaw())==BTN_NONE);

};
Example #25
0
void lcdPrintln(const char *string){
  lcdPrint(string);
  lcdNl();
}
Example #26
0
void lcdCheckNl(void){
    if(x>RESX)
         lcdNl();
}
Example #27
0
uint8_t execute_file (const char * fname){
    FRESULT res;
    FIL file;
    UINT readbytes;
    void (*dst)(void);
    uint32_t version=0;

    res=f_open(&file, fname, FA_OPEN_EXISTING|FA_READ);
    if (res!=FR_OK){
	lcdPrintln(f_get_rc_string(res));
	lcdDisplay();
	return -1;
    };

    res = f_read(&file, &version, sizeof(uint32_t), &readbytes);
    if(res!=FR_OK){
	lcdPrintln(f_get_rc_string(res));
	lcdDisplay();
        return -1;
    };

    if (version>jumptable_len){
	lcdPrintln("l0dable incompat.");
	lcdPrint(IntToStr(jumptable_len,4,F_HEX));
	lcdPrint(" < ");
	lcdPrintln(IntToStr(version,4,F_HEX));
	lcdDisplay();
        return -1;
    };

    res = f_read(&file, &dst, sizeof(uint32_t), &readbytes);
    if(res!=FR_OK){
	lcdPrintln(f_get_rc_string(res));
	lcdDisplay();
        return -1;
    };

    if ((uintptr_t)dst<l0dable_start || (uintptr_t)dst>(l0dable_start+l0dable_len)){
	lcdPrintln("l0daddr illegal");
	lcdPrint(IntToStr((uintptr_t)dst,8,F_HEX));
	lcdDisplay();
        return -1;
    };


    res = f_read(&file, (uint8_t *)l0dable_start, l0dable_len, &readbytes);
    if(res!=FR_OK){
	lcdPrintln(f_get_rc_string(res));
	lcdDisplay();
        return -1;
    };

    if(readbytes>=l0dable_len){
	lcdPrintln("l0dable too long.");
	lcdDisplay();
	return -1;
    };

    lcdPrint(IntToStr(readbytes,5,F_LONG));
    lcdPrintln(" bytes...");

    dst=(void (*)(void)) ((uintptr_t)dst|1); // Enable Thumb mode!

#if 0
    lcdPrint("dst= "); lcdPrint(IntToStr((uintptr_t)dst,8,F_HEX)); lcdNl();
    lcdPrint("len= "); lcdPrint(IntToStr((uintptr_t)&_l0dable_len,8,F_HEX)); lcdNl();
    lcdPrint("jt=  "); lcdPrint(IntToStr(jumptable_len,8,F_HEX)); lcdNl();
    lcdPrint("ver= "); lcdPrint(IntToStr(version,8,F_HEX)); lcdNl();
    lcdDisplay();
#endif

    dst();
    return 0;
}
Example #28
0
void handleMenu(const struct MENU *the_menu) {
    uint8_t back = 0;
    int8_t menuselection = 0;
    uint8_t numentries;
    uint8_t visible_lines = 0;
    uint8_t current_offset = 0;

    if (the_menu == NULL) return;

    setSystemFont();

    for (numentries = 0; the_menu->entries[numentries].text != NULL ; numentries++);

    if(the_menu->entries[numentries-1].text[0]=='|' && !GLOBAL(develmode))
        numentries--;

    visible_lines = lcdGetVisibleLines()-1; // subtract title line

    if(menuflags&MENU_BIG)
        visible_lines/=2;

#ifdef SAFETY
    if (visible_lines < 2) return;
#endif

    while (!back) {
        // Display current menu page
        lcdClear();
        lcdPrintln(the_menu->title);

        for (uint8_t i = current_offset; i < (visible_lines + current_offset) && i < numentries; i++) {
            if(menuflags&MENU_BIG)
                lcdNl();
            if (i == menuselection) {
                lcdPrint("*");
            }
            lcdSetCrsrX(14);
            lcdPrintln(the_menu->entries[i].text);
        }
        lcdRefresh();

        switch (getInputWaitTimeout((menuflags&MENU_TIMEOUT)?15000:0)) {
            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;
            case BTN_RIGHT:
                if (the_menu->entries[menuselection].callback!=NULL)
                    the_menu->entries[menuselection].callback();
				
				if (menuflags&MENU_JUSTONCE)
					return;
				
                break;
            case BTN_ENTER:
                lcdClear();
//                lcdPrintln("Called...");
//                lcdRefresh();
                getInputWaitRelease();
                if (the_menu->entries[menuselection].callback!=NULL)
                    the_menu->entries[menuselection].callback();
                lcdRefresh();
				
				if (menuflags&MENU_JUSTONCE)
					return;

//                getInputWait();

                break;
            case BTN_NONE: /* timeout */
                return;
            default:
                /* NOTREACHED */
                break;
        }
        getInputWaitRelease();
    }
    return;
}
Example #29
0
//# MENU config
void ram(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++){
        if(!the_config[i].disabled)
            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,1,0));
        lcdPrint("/");
        lcdPrint(IntToStr(((numentries-1)/visible_lines)+1,1,0));
        lcdPrint("]");
        lcdNl();

        lcdNl();

        uint8_t j=0;
        for (uint8_t i=0;i<current_offset;i++)
            while (the_config[++j].disabled);

        uint8_t t=0;
        for (uint8_t i=0;i<menuselection;i++)
            while (the_config[++t].disabled);

        for (uint8_t i = current_offset; i < (visible_lines + current_offset) && i < numentries; i++,j++) {
            while(the_config[j].disabled)j++;
            if(i==0){
                lcdPrintln("Save changes:");
                if (i == t)
                    lcdPrint("*");
                lcdSetCrsrX(14);
                if (i == t)
                    lcdPrintln("YES");
                else
                    lcdPrintln("no");
            }else{
                lcdPrintln(the_config[j].name);
                if (j == t)
                    lcdPrint("*");
                lcdSetCrsrX(14);
                lcdPrint("<");
                lcdPrint(IntToStr(the_config[j].value,3,F_LONG));
                lcdPrintln(">");
            };
        lcdRefresh();
        }

        switch (getInputWaitRepeat()) {
            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[t].value >
                        the_config[t].min)
                    the_config[t].value--;
                if(the_config[t].value > the_config[t].max)
                    the_config[t].value=
                        the_config[t].max;
                applyConfig();
                break;
            case BTN_RIGHT:
                if(the_config[t].value <
                        the_config[t].max)
                    the_config[t].value++;
                if(the_config[t].value < the_config[t].min)
                    the_config[t].value=
                        the_config[t].min;
                applyConfig();
                break;
            case BTN_ENTER:
                if(menuselection==0)
                    saveConfig();
                return;
        }
    }
    /* NOTREACHED */
}
Example #30
0
int main(void)
{
	cpu_clock_init_();
//	cpu_clock_pll1_max_speed();
	scu_pinmux(RF_EN_PIN,SCU_GPIO_NOPULL|RF_EN_FUNC);
	GPIO_DIR(RF_EN_GPORT) |= RF_EN_GPIN;
	gpio_clear(RF_EN_GPORT, RF_EN_GPIN); /* RF off */

    // Config LED as out
	scu_pinmux(LED1_PIN,SCU_GPIO_NOPULL|LED1_FUNC);
	GPIO_DIR(LED1_GPORT) |= LED1_GPIN;

	inputInit();

    lcdInit();
    lcdFill(0xff);
	setSystemFont();
	char tu=0,td=0,tl=0,tr=0,tm=0;
	char led=0;
	lcdPrintln("Sec-Test v2");
	lcdPrintln("");

	int ctr=0;
	int k=0;
	/* Blink LED1 on the board. */
	while (1) 
	{
		lcdSetCrsr(0,16);
		lcdPrint(IntToStr(tu,2,F_HEX)); lcdPrintln(" Up");
		lcdPrint(IntToStr(td,2,F_HEX)); lcdPrintln(" Down");
		lcdPrint(IntToStr(tl,2,F_HEX)); lcdPrintln(" Left");
		lcdPrint(IntToStr(tr,2,F_HEX)); lcdPrintln(" Right");
		lcdPrint(IntToStr(tm,2,F_HEX)); lcdPrintln(" Enter");
		lcdDisplay(); 
		switch(getInput()){
			case BTN_UP:
				tu=1-tu;
				if (tu){
				}else{
				};
				break;
			case BTN_DOWN:
				td=1-td;
				if (td){
				}else{
				};
				break;
			case BTN_LEFT:
				tl=1-tl;
				if (tl){
				}else{
				};
				break;
			case BTN_RIGHT:
				tr=1-tr;
				if (tr){
				}else{
				};
				break;
			case BTN_ENTER:
				tm=1-tm;
				if (tm){
				}else{
				};
				break;
		};

		led=1-led;
		if (led){
			gpio_set(LED1_GPORT, LED1_GPIN); /* LED on */
		}else{
			gpio_clear(LED1_GPORT, LED1_GPIN); /* LED off */
//			delayNop(200000);
		};

		ctr++;
		lcdNl();
		lcdPrint(IntToStrX(ctr,4));
	}

	return 0;
}