Beispiel #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);
	}
Beispiel #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);
	}
}
Beispiel #3
0
static void createWidgets(void) {
    GWidgetInit wi;

    // Apply some default values for GWIN
    gwinWidgetClearInit(&wi);

    // Apply the container parameters
    wi.g.show = FALSE;
    wi.g.width = 200;
    wi.g.height = 150;
    wi.g.y = 10;
    wi.g.x = 10;
    wi.text = "Container";
    ghContainer = gwinContainerCreate(0, &wi, GWIN_CONTAINER_BORDER);
    wi.g.show = TRUE;

    // Apply the button parameters
    wi.g.width = 120;
    wi.g.height = 30;
    wi.g.y = 10;
    wi.g.x = 10;
    wi.text = "Button";
    wi.g.parent = ghContainer;
    ghButton = gwinButtonCreate(0, &wi);

    // Make the container become visible - therefore all its children
    // become visible as well
    gwinShow(ghContainer);
}
Beispiel #4
0
/**
 * Create the widgets.
 */
static void createWidgets(void) {
	GWidgetInit		wi;

	gwinWidgetClearInit(&wi);

	// Create the console - set colors before making it visible
	wi.g.show = FALSE;
	wi.g.x = 0; wi.g.y = 0;
	wi.g.width = gdispGetWidth(); wi.g.height = gdispGetHeight()/2;
	ghConsole = gwinConsoleCreate(0, &wi.g);
	gwinSetColor(ghConsole, Black);
	gwinSetBgColor(ghConsole, HTML2COLOR(0xF0F0F0));
	gwinShow(ghConsole);
	gwinClear(ghConsole);

	// Create the keyboard
	wi.g.show = TRUE;
	wi.g.x = 0; wi.g.y = gdispGetHeight()/2;
	wi.g.width = gdispGetWidth(); wi.g.height = gdispGetHeight()/2;
	ghKeyboard = gwinKeyboardCreate(0, &wi);
}
Beispiel #5
0
int main(void) {
	GEvent *			pe;

	// Initialize the display
	gfxInit();

	// Set the widget defaults
	font = gdispOpenFont("*");			// Get the first defined font.
	gwinSetDefaultFont(font);
	gwinSetDefaultStyle(&WhiteWidgetStyle, FALSE);
	gdispClear(White);

	// Create the gwin windows/widgets
	createWidgets();

    // Assign toggles and dials to specific buttons & sliders etc.
	#if GINPUT_NEED_TOGGLE
		gwinAttachToggle(ghButton1, 0, 0);
		gwinAttachToggle(ghButton2, 0, 1);
	#endif
	#if GINPUT_NEED_DIAL
		gwinAttachDial(ghSlider1, 0, 0);
		gwinAttachDial(ghSlider3, 0, 1);
	#endif

	// Make the console visible
	gwinShow(ghConsole);
	gwinClear(ghConsole);

    // We want to listen for widget events
	geventListenerInit(&gl);
	gwinAttachListener(&gl);
	gtimerInit(&FlashTimer);

	#if !GWIN_NEED_TABSET
		// Press the Tab we want visible
		gwinRadioPress(ghTabButtons);
	#endif

	while(1) {
		// Get an Event
		pe = geventEventWait(&gl, TIME_INFINITE);

		switch(pe->type) {
		case GEVENT_GWIN_BUTTON:
			gwinPrintf(ghConsole, "Button %s\n", gwinGetText(((GEventGWinButton *)pe)->gwin));
			break;

		case GEVENT_GWIN_SLIDER:
			gwinPrintf(ghConsole, "Slider %s=%d\n", gwinGetText(((GEventGWinSlider *)pe)->gwin), ((GEventGWinSlider *)pe)->position);
			break;

		case GEVENT_GWIN_CHECKBOX:
			gwinPrintf(ghConsole, "Checkbox %s=%s\n", gwinGetText(((GEventGWinCheckbox *)pe)->gwin), ((GEventGWinCheckbox *)pe)->isChecked ? "Checked" : "UnChecked");

			// If it is the Disable All checkbox then do that.
			if (((GEventGWinCheckbox *)pe)->gwin == ghCheckDisableAll) {
				gwinPrintf(ghConsole, "%s All\n", ((GEventGWinCheckbox *)pe)->isChecked ? "Disable" : "Enable");
				setEnabled(!((GEventGWinCheckbox *)pe)->isChecked);

			// If it is the toggle button checkbox start the flash.
			} else if (((GEventGWinCheckbox *)pe)->gwin == ghCheckbox3) {
				gwinFlash(ghCheckbox3);
				gtimerStart(&FlashTimer, FlashOffFn, 0, FALSE, 3000);
			}
			break;

		case GEVENT_GWIN_LIST:
			gwinPrintf(ghConsole, "List %s Item %d %s\n", gwinGetText(((GEventGWinList *)pe)->gwin), ((GEventGWinList *)pe)->item,
					gwinListItemIsSelected(((GEventGWinList *)pe)->gwin, ((GEventGWinList *)pe)->item) ? "Selected" : "Unselected");
			break;

		case GEVENT_GWIN_RADIO:
			gwinPrintf(ghConsole, "Radio Group %u=%s\n", ((GEventGWinRadio *)pe)->group, gwinGetText(((GEventGWinRadio *)pe)->gwin));

			switch(((GEventGWinRadio *)pe)->group) {
			#if !GWIN_NEED_TABSET
				case GROUP_TABS:

					// Set control visibility depending on the tab selected
					setTab(((GEventGWinRadio *)pe)->gwin);

					// We show the state of some of the GUI elements here
					setProgressbar(((GEventGWinRadio *)pe)->gwin == ghTabProgressbar);
					if (((GEventGWinRadio *)pe)->gwin == ghTabLabels)
						setLabels();
					break;
			#endif

			case GROUP_COLORS:
				{
					const GWidgetStyle	*pstyle;

					gwinPrintf(ghConsole, "Change Color Scheme\n");

					if (((GEventGWinRadio *)pe)->gwin == ghRadioYellow)
						pstyle = &YellowWidgetStyle;
					else if (((GEventGWinRadio *)pe)->gwin == ghRadioBlack)
						pstyle = &BlackWidgetStyle;
					else
						pstyle = &WhiteWidgetStyle;

					// Clear the screen to the new color
					gdispClear(pstyle->background);

					// Update the style on all controls
					gwinSetDefaultStyle(pstyle, TRUE);
				}
				break;
			}
			break;

		#if GWIN_NEED_TABSET
			case GEVENT_GWIN_TABSET:
				gwinPrintf(ghConsole, "TabPage %u (%s)\n", ((GEventGWinTabset *)pe)->nPage, gwinTabsetGetTitle(((GEventGWinTabset *)pe)->ghPage));

				// We show the state of some of the GUI elements here
				setProgressbar(((GEventGWinTabset *)pe)->ghPage == ghPgProgressbars);
				if (((GEventGWinTabset *)pe)->ghPage == ghPgLabels)
					setLabels();
				break;
		#endif

		default:
			gwinPrintf(ghConsole, "Unknown %d\n", pe->type);
			break;
		}
	}
	return 0;
}
Beispiel #6
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);
	}
}