Exemple #1
0
	/**
	 * Set the visibility of widgets based on which tab is selected.
	 */
	static void setTab(GHandle tab) {
		/* Make sure everything is invisible first */
		gwinHide(ghPgButtons);
		gwinHide(ghPgSliders);
		gwinHide(ghPgCheckboxes);
		gwinHide(ghPgLabels);
		gwinHide(ghPgRadios);
		gwinHide(ghPgLists);
		gwinHide(ghPgImages);
		gwinHide(ghPgProgressbars);

		/* Turn on widgets depending on the tab selected */
		if (tab == ghTabButtons)
			gwinShow(ghPgButtons);
		else if (tab == ghTabSliders)
			gwinShow(ghPgSliders);
		else if (tab == ghTabCheckboxes)
			gwinShow(ghPgCheckboxes);
		else if (tab == ghTabLabels)
			gwinShow(ghPgLabels);
		else if (tab == ghTabRadios)
			gwinShow(ghPgRadios);
		else if (tab == ghTabLists)
			gwinShow(ghPgLists);
		else if (tab == ghTabImages)
			gwinShow(ghPgImages);
		else if (tab == ghTabProgressbar)
			gwinShow(ghPgProgressbars);
	}
Exemple #2
0
int main(void)
{
	// Initialize ChibiOS
	halInit();
	chSysInit();

	// Initialize uGFX
	gfxInit();

	// Initialize our own stuff
	startupInit();

	// Get the command prompt (via USB) up and running
	cmdCreate();

	// Get the SD-Card stuff done
	sdcardInit();

	while (true) {
        cmdManage();
		if(SDU1.config->usbp->state == USB_ACTIVE){
			gwinShow(ghImageUSB);
		} else {
			gwinHide(ghImageUSB);
		}

		// Until the statusbar widget is ready...
		gwinSetVisible(ghImageSDC, sdcardReady());

        sdCardEvent();

		chThdSleepMilliseconds(500);
	}
}
Exemple #3
0
static THD_FUNCTION(ThreadGFXEvent, arg)
{
	(void)arg;

	chRegSetThreadName("GFXEvent");

	GEvent* pe;
	static RTCDateTime timespec;
	struct tm timeinfo;
	struct tm tim;
	struct tm *canary;
	static time_t unix_time;
	while (true) {
		pe = geventEventWait(&gl, TIME_INFINITE);
		switch (pe->type) {
			case GEVENT_GWIN_BUTTON:
				if (((GEventGWinButton*)pe)->gwin == ghBtnSettings) {
					createSettingsFrame();
					gwinShow(ghFrame1);
					updateGraph = false;
					updateSettingTime = true;
				} else if (((GEventGWinButton*)pe)->gwin == ghBtnSave) {
					timeinfo.tm_hour = atoi(gwinListGetSelectedText(ghListHour));
					timeinfo.tm_min = atoi(gwinListGetSelectedText(ghListMin));
					timeinfo.tm_sec = 0;
					timeinfo.tm_mday = atoi(gwinListGetSelectedText(ghListDay));
					timeinfo.tm_mon = gwinListGetSelected(ghListMonth);
					timeinfo.tm_year = atoi(gwinListGetSelectedText(ghListYear))-1900;
					unix_time = mktime(&timeinfo);
					canary = localtime_r(&unix_time, &tim);
					osalDbgCheck(&tim == canary);
					rtcConvertStructTmToDateTime(&tim, 0, &timespec);
					rtcSetTime(RTC_DRIVER, &timespec);
				} else if (((GEventGWinButton*)pe)->gwin == ghBtnTime) {
					updateGraph = false;
					gwinShow(ghListFreq);
				}
				break;

			case GEVENT_GWIN_CHECKBOX:
				if (((GEventGWinCheckbox*)pe)->gwin == ghCheckBoxHR) {
					if (((GEventGWinCheckbox*)pe)->isChecked)
						use12HR = true;
					else
						use12HR = false;
				}
				break;

			case GEVENT_GWIN_CLOSE:
				updateGraph = true;
				updateSettingTime = false;
				switch (activeGraph) {
					case 0:
						drawGraphLines(ghContainerGraphC);
						break;

					case 1:
						drawGraphLines(ghContainerGraphV);
						break;

					case 2:
						drawGraphLines(ghContainerGraphW);
						break;

					case 3:
						drawGraphLines(ghContainerGraphCV_1);
						drawGraphLines(ghContainerGraphCV_2);
						break;

					default:
						break;
				}
				break;

			case GEVENT_GWIN_RADIO:
				activeGraph = atoi(gwinGetText(((GEventGWinRadio *)pe)->gwin));
				setActiveGraph(activeGraph);
				break;

			case GEVENT_GWIN_LIST:
				if (((GEventGWinList*)pe)->gwin == ghListFreq)  {
					char str[5];
					uint8_t val = atoi(gwinListGetSelectedText(ghListFreq));
					GRAPH_Refresh = ((1.0/val)*1000);
					snprintf(str, 5, "%d%s", val, "Hz");
					gwinSetText(ghBtnTime, str, true);
					chThdSleepMilliseconds(10);
					gwinHide(ghListFreq);
					updateGraph = true;

					switch (activeGraph) {
					case 0:
						drawGraphLines(ghContainerGraphC);
						break;

					case 1:
						drawGraphLines(ghContainerGraphV);
						break;

					case 2:palSetPadMode(GPIOA, 5, PAL_MODE_OUTPUT_PUSHPULL); palClearPad(GPIOA, 5);
						drawGraphLines(ghContainerGraphW);
						break;

					case 3:
						drawGraphLines(ghContainerGraphCV_1);
						drawGraphLines(ghContainerGraphCV_2);
						break;

					default:
						break;
					}

				}

				break;
			default:
				break;
		}

		chThdSleepMilliseconds(500);
	}
}