Esempio n. 1
0
static void inputMove() {
	char *cur = s_input.line+s_input.pos+s_input.dcursor;
    switch(getInputWaitRepeat()){
        case BTN_LEFT:
            if (s_input.dcursor >0) {
                s_input.dcursor --;
            } else if (s_input.pos > 0) {
                s_input.pos --;
            }
            break;
        case BTN_RIGHT:
            if (s_input.dcursor <RESX/CHARWIDTH-1 && s_input.pos + s_input.dcursor < s_input.maxlength) {
                if (*cur == 0) {
                    *cur = CHARSPACE;
                }
                s_input.dcursor ++;
            } else if (s_input.pos + RESX/CHARWIDTH < s_input.maxlength) {
                s_input.pos++;
                if (*cur == 0) {
                    *cur = CHARSPACE;
                }
            }			
            break;
        case BTN_UP:
            if (*cur <= s_input.asciistart) {
                *cur = s_input.asciiend;
            } else if (*cur > s_input.asciiend) {
                *cur = s_input.asciiend;
            } else  {
                *cur = *cur - 1;
            }
            break;
        case BTN_DOWN:
            if (*cur >= s_input.asciiend) {
                *cur = s_input.asciistart;
            } else if (*cur < s_input.asciistart) {
                *cur = s_input.asciistart;
            } else {
                *cur = *cur + 1;
            }
            break;
        case BTN_ENTER:
            s_input.done = true;
//            getInputWaitRelease();
            break;
    }
}
Esempio n. 2
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();

}
Esempio n. 3
0
static void intinMove() {
	switch(getInputWaitRepeat()){
        case BTN_LEFT:
            if (s_int.pos > 0) {
                s_int.pos --;
            }
            break;
        case BTN_RIGHT:
            if (s_int.pos < s_int.digits-1) {
                s_int.pos++;
            }
            break;
        case BTN_UP:
            s_int.the_number += power(10,s_int.digits-s_int.pos-1);
            break;
        case BTN_DOWN:
          s_int.the_number -= power(10,s_int.digits-s_int.pos-1);
            break;
        case BTN_ENTER:
            s_int.done = true;
//            getInputWaitRelease();
            break;
    }
}
Esempio n. 4
0
File: lcd.c Progetto: n0p/f1rmware
//# MENU lcd
void lcd_menu() {
    getInputWaitRelease();
    lcdClear();
    lcdPrintln("LCD:");
    lcdDisplay();
    ON(LED1);

    uint16_t x,y;
    uint8_t rgb=0;
    uint8_t ct=0x3a;
    uint16_t rgba[]= { RGB(0xff,0,0),   RGB(0,0xff,0),   RGB(0,0,0xff),
                       RGB(0,0xff,0xff),RGB(0xff,0,0xff),RGB(0xff,0xff,0),
                       RGB(0xff,0xff,0xff),0
                     };
    while(1) {
        switch(getInputWaitRepeat()) {
        case BTN_DOWN:
            lcd_select();
            lcdWrite(TYPE_CMD,0x3a);
            lcdWrite(TYPE_DATA,5);
            lcdWrite(TYPE_CMD,0x2C);
            for (y=0; y<128; y++) {
                for (x=0; x<RESX; x++) {
                    if (x<20) {
                        if(y<64) {
                            PIX(0xff,(0xff-(0xff&(y<<2))),(0xff-(0xff&(y<<2))));
                        } else {
                            PIX((0xff-(0xff&(y<<2))),0,0);
                        };
                    } else if (x <40) {
                        if(y<64) {
                            PIX((0xff-(0xff&(y<<2))),0xff,(0xff-(0xff&(y<<2))));
                        } else {
                            PIX(0,(0xff-(0xff&(y<<2))),0);
                        };
                    } else if (x <60) {
                        if(y<64) {
                            PIX((0xff-(0xff&(y<<2))),(0xff-(0xff&(y<<2))),0xff);
                        } else {
                            PIX(0,0,(0xff-(0xff&(y<<2))));
                        };
                    } else if (x <80) {
                        if(y<64) {
                            PIX(((0xff&(y<<2))),0,0);
                        } else {
                            PIX(0xff,((0xff&(y<<2))),((0xff&(y<<2))));
                        };
                    } else if (x <100) {
                        if(y<64) {
                            PIX(0,((0xff&(y<<2))),0);
                        } else {
                            PIX(((0xff&(y<<2))),0xff,((0xff&(y<<2))));
                        };
                    } else if (x <120) {
                        if(y<64) {
                            PIX(0,0,((0xff&(y<<2))));
                        } else {
                            PIX(((0xff&(y<<2))),((0xff&(y<<2))),0xff);
                        };
                    } else {
                        PIX(0,0,0);
                    }
                };
            };
            for (y=128; y<RESY; y++) {
                for (x=0; x<RESX; x++) {
                    PIX(0,0,0);
                };
            };
            lcd_deselect();
            break;
        case BTN_LEFT:
            ct--;
            lcd_select();
            lcdWrite(TYPE_CMD,0x25);
            lcdWrite(TYPE_DATA, ct);
            lcd_deselect();
            break;
        case BTN_RIGHT:
            ct++;
            lcd_select();
            lcdWrite(TYPE_CMD,0x25);
            lcdWrite(TYPE_DATA, ct);
            lcd_deselect();
            break;
        case BTN_UP:
            lcd_select();
            lcdWrite(TYPE_CMD,0x3a);
            lcdWrite(TYPE_DATA,5);
            lcdWrite(TYPE_CMD,0x2C);
            if(rgb==0) {
                for (y=0; y<RESY; y++) {
                    for (x=0; x<RESX; x++) {
                        if(x==0 || x==RESX-1 || y==0 || y==RESY-1) {
                            PIX(0xff,0,0);
                        } else if(x==1 || x==RESX-2 || y==1 || y==RESY-2) {
                            PIX(0xff,0xff,0);
                        } else if(x==2 || x==RESX-3 || y==2 || y==RESY-3) {
                            PIX(0,0,0xff);
                        } else {
                            PIX(0xff,0xff,0xff);
                        };
                    };
                };
            } else {
                for (y=0; y<RESY; y++) {
                    for (x=0; x<RESX; x++) {
                        lcdWrite(TYPE_DATA,rgba[rgb-1]>>8);
                        lcdWrite(TYPE_DATA,rgba[rgb-1]&0xff);
                    };
                };
            };
            lcd_deselect();
            rgb=(rgb+1)%(1+(sizeof(rgba)/sizeof(*rgba)));
            break;
        case BTN_ENTER:
            lcd_select();
            lcdWrite(TYPE_CMD,0x3a);
            lcdWrite(TYPE_DATA,2);
            lcd_deselect();
            return;
        };
        getInputWaitRelease();
    };
};
Esempio n. 5
0
int selectFile(char *filename, const char *extension)
{
    int skip = 0;
    char key;
    int selected = 0;
    font=&Font_7x8;
    while(1){
        char files[PERPAGE][FLEN];
        int count = getFiles(files, PERPAGE, skip, extension);
        if(!count){
            lcdPrintln("No Files?");
            lcdRefresh();
            getInputWait();
            getInputWaitRelease();
            return -1;
        };

        if(count<PERPAGE && selected==count){
            skip--;
            continue;
        };
        
        redraw:
        lcdClear();
        lcdPrintln("Select file:");
        for(int i=0; i<count; i++){
            if( selected == i )
                lcdPrint("*");
            else
                lcdPrint(" ");
            lcdSetCrsrX(14);
            int dot=-1;
            for(int j=0;files[j];j++)
                if(files[i][j]=='.'){
                    files[i][j]=0;
                    dot=j;
                    break;
                };
            lcdPrintln(files[i]);
            if(dot>0)
                files[i][dot]='.';
        }
        lcdRefresh();
        key=getInputWaitRepeat();
        switch(key){
            case BTN_DOWN:
                if( selected < count-1 ){
                    selected++;
                    goto redraw;
                }else{
                    skip++;
                }
                break;
            case BTN_UP:
                if( selected > 0 ){
                    selected--;
                    goto redraw;
                }else{
                    if( skip > 0 ){
                        skip--;
                    }
                }
                break;
            case BTN_LEFT:
                return -1;
            case BTN_ENTER:
            case BTN_RIGHT:
                strcpy(filename, files[selected]);
		getInputWaitRelease(); // catch this event so the app does not get it
                return 0;
        }
    }
}
Esempio n. 6
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 */
}
Esempio n. 7
0
File: select.c Progetto: derf/r0ket
int selectFile(char *filename, char *extension)
{
    int skip = 0;
    int selected = 0;
    char pwd[FLEN];
    memset(pwd, 0, FLEN);
    font=&Font_7x8;

	while(1) {
		int total;
		char files[PERPAGE][FLEN+2];
		int count = retrieve_files(files, PERPAGE, skip, extension, pwd, &total);
		if (selected >= count) {
			selected = count - 1;
		}

		/* optimization: don't reload filelist if only redraw needed */
		redraw:

		lcdClear();
		lcdPrint("[");
		lcdPrint(pwd);
		lcdPrintln("]");

		for (int i = 0; i < 98; i++) {
			lcdSetPixel(i, 9, 1);
		}

		lcdSetCrsr(0, 12);

		if (!count) {
			lcdPrintln("- empty");
		} else {
			for (int i = 0; i < count; i++) {
				if (selected == i) {
					lcdPrint("*");
				} else {
					lcdPrint(" ");
				}
				lcdSetCrsrX(14);

				lcdPrintln(files[i]);
			}
		}
		lcdRefresh();

		char key = getInputWaitRepeat();
		switch (key) {
		case BTN_DOWN:
			if (selected < count - 1) {
				selected++;
				goto redraw;
			} else {
				if (skip < total - PERPAGE) {
					skip++;
				} else {
					skip = 0;
					selected = 0;
					continue;
				}
			}
			break;
		case BTN_UP:
			if (selected > 0) {
				selected--;
				goto redraw;
			} else {
				if (skip > 0) {
					skip--;
				} else {
					skip = total - PERPAGE;
					if (skip < 0) {
						skip = 0;
					}
					selected = PERPAGE - 1;
					continue;
				}
			}
			break;
		case BTN_LEFT:
			if (pwd[0] == 0) {
				return -1;
			} else {
				pwd[0] = 0;
				continue;
			}
		case BTN_ENTER:
		case BTN_RIGHT:
			if (count) {
				if (files[selected][strlen(files[selected]) - 1] == '/') {
					/* directory selected */
					strcpy(pwd, files[selected]);
					continue;
				} else {
					strcpy(filename, pwd);
					strcpy(filename + strlen(pwd), files[selected]);
					getInputWaitRelease(); /* ?! */
					return 0;
				}
			}
		}
	}
}