예제 #1
0
void drawFrame(Window* cur_window) {

	int i;


	//prints("[WYG] Drawing frame for window ");
	//printDecimal(cur_window->handle);
	//pchar('\n');

	//Outer border
	bmpDrawPanel(cur_window->context, 0, 0, cur_window->w, cur_window->h, RGB(238, 203, 137), 1, 0);

	//Title border
	bmpDrawPanel(cur_window->context, 3, 3, cur_window->w - 6, 22, RGB(238, 203, 137), 1, 1);

	//Body border
	bmpDrawPanel(cur_window->context, 3, 27, cur_window->w - 6, cur_window->h - 30, RGB(238, 203, 137), 1, 1);

	//Left frame
	bmpFillRect(cur_window->context, 1, 1, 2, cur_window->h - 2, RGB(238, 203, 137));

	//Right frame
	bmpFillRect(cur_window->context, cur_window->w - 3, 1, 2, cur_window->h - 2, RGB(238, 203, 137));

	//Top frame
	bmpFillRect(cur_window->context, 3, 1, cur_window->w - 6, 2, RGB(238, 203, 137));

	//Mid frame
	bmpFillRect(cur_window->context, 3, 25, cur_window->w - 6, 2, RGB(238, 203, 137));

	//Bottom frame
	bmpFillRect(cur_window->context, 3, cur_window->h - 3, cur_window->w - 6, 2, RGB(238, 203, 137));

	//Button
	bmpDrawPanel(cur_window->context, cur_window->w - 24, 4, 20, 20, RGB(238, 203, 137), 1, 0);
	bmpFillRect(cur_window->context, cur_window->w - 23, 5, 18, 18, RGB(238, 203, 137));

	drawTitlebar(cur_window, 0);

	cur_window->frame_needs_redraw = 0;
}
예제 #2
0
void UI::updateValues() {
	drawTitlebar(m_data->time_hour, m_data->time_minute, m_data->time_second, batteryPercentage(m_data->battery_voltage));

	// debug
	//m_lcd->drawStringF(0,312, 1, RED, WHITE, "%2.2f %d  ", m_data->battery_voltage, m_data->geiger_voltage);

	switch (m_page) {
		case PAGE_MEASURE: {
			m_lcd->drawStringF(8,  40, 2, BLUE, WHITE, "%2.2f%cC", m_data->bmp180_temp,247);
			m_lcd->drawStringF(8,  72, 2, BLUE, WHITE, "%4uhPa", m_data->bmp180_pressure / 100);
			m_lcd->drawStringF(8, 104, 2, BLUE, WHITE, "%4.2fm", m_data->bmp180_altitude);
			m_lcd->drawStringF(8, 136, 2, PURPLE, WHITE, "%2.2fmgm%c", m_data->gp2y10_dust, 254);
			m_lcd->drawStringF(8, 168, 2, DARKGREEN, WHITE, "%4.2fppm", m_data->vz89_co2);
			m_lcd->drawStringF(8, 200, 2, DARKGREEN, WHITE, "%4.2fppb", m_data->vz89_voc);
			m_lcd->drawStringF(8, 232, 2, RED, WHITE, "%luCPM", m_data->geiger_cpm);

			float bmp180_temp = m_data->getBMP180Temp_scaled(),
					bmp180_altitude = m_data->getBMP180Altitude_scaled(),
					gp2y10_dust = m_data->getGP2Y10Dust_scaled(),
					vz89_co2 = m_data->getVZ89CO2_scaled() ,
					vz89_voc = m_data->getVZ89VOC_scaled();
			uint32_t bmp180_pressure = m_data->getBMP180Pressure_scaled(),
			 		geiger_cpm = m_data->getGeigerCPM_scaled();

			if (m_chartX == 120) {
				m_lcd->drawPixel(m_chartX, 64 - bmp180_temp, BLUE);
				m_lcd->drawPixel(m_chartX, 96 - bmp180_pressure, BLUE);
				m_lcd->drawPixel(m_chartX,128 - bmp180_altitude, BLUE);
				m_lcd->drawPixel(m_chartX,160 - gp2y10_dust, PURPLE);
				m_lcd->drawPixel(m_chartX,192 - vz89_co2, DARKGREEN);
				m_lcd->drawPixel(m_chartX,224 - vz89_voc, DARKGREEN);
				m_lcd->drawPixel(m_chartX,256 - geiger_cpm, RED);
			} else {
				m_lcd->drawLine(m_chartX, 64 - m_data->bmp180_temp_last, m_chartX, 64 - bmp180_temp, BLUE);
				m_lcd->drawLine(m_chartX, 96 - m_data->bmp180_pressure_last, m_chartX, 96 - bmp180_pressure, BLUE);
				m_lcd->drawLine(m_chartX, 128 - m_data->bmp180_altitude_last, m_chartX, 128 - bmp180_altitude, BLUE);
				m_lcd->drawLine(m_chartX, 160 - m_data->gp2y10_dust_last, m_chartX, 160 - gp2y10_dust, PURPLE);
				m_lcd->drawLine(m_chartX, 192 - m_data->vz89_co2_last, m_chartX, 192 - vz89_co2, DARKGREEN);
				m_lcd->drawLine(m_chartX, 224 - m_data->vz89_voc_last, m_chartX, 224 - vz89_voc, DARKGREEN);
				m_lcd->drawLine(m_chartX, 256 - m_data->geiger_cpm_last, m_chartX, 256 - geiger_cpm, RED);
			}

			if (m_chartX < 240) {
				m_chartX ++;
				// clear in front
				m_lcd->drawRectFilled(m_chartX, 32, 1, 225, WHITE);
				// save last values
				m_data->bmp180_temp_last = bmp180_temp;
				m_data->bmp180_pressure_last = bmp180_pressure;
				m_data->bmp180_altitude_last = bmp180_altitude;
				m_data->gp2y10_dust_last = gp2y10_dust;
				m_data->vz89_co2_last = vz89_co2;
				m_data->vz89_voc_last = vz89_voc;
				m_data->geiger_cpm_last = geiger_cpm;

			}
			else
				m_chartX  = 120;
		}
		break;
		case PAGE_MONITOR: {
			m_lcd->drawStringF(8,  104, 2, BLUE, WHITE,      "Sent:    %09luB", m_data->serial_sent);
			m_lcd->drawStringF(8,  120, 2, BLUE, WHITE,      "Received:%09luB", m_data->serial_recv);
			m_lcd->drawStringF(8,  168, 2, DARKGREEN, WHITE, "Sent:    %09luB", m_data->wlan_sent);
			m_lcd->drawStringF(8,  184, 2, DARKGREEN, WHITE, "Received:%09luB", m_data->wlan_recv);
			m_lcd->drawStringF(8,  216, 2, BLACK, WHITE, "Tube: %3uV", m_data->geiger_voltage);
			m_lcd->drawStringF(8,  232, 2, BLACK, WHITE, "Battery: %2.2fV", m_data->battery_voltage);
		} break;
		case PAGE_SETTINGS: {
			// nothing to update here
		} break;
		case PAGE_CALIBRATE: {
			m_lcd->drawStringF(CENTERX,  CENTERY, 2, BLUE, WHITE, "%04d,%04d,%04d", m_touch->lastRawX, m_touch->lastRawY, m_touch->lastRawZ);
			m_lcd->drawPixel(m_touchX, m_touchY,3, RED);
		}
		break;
		case PAGE_WLAN: {
			if (m_butCount != m_data->freeAPCount + 1) // count the back button
				drawPage(PAGE_WLAN);
		}
	}
}
예제 #3
0
Window* newWindow(unsigned int width, unsigned int height, unsigned char flags, unsigned int pid) {

	static int next_handle = 1;
	Window *new_window, *temp_window;
	unsigned int i, bufsz;

	if (!(new_window = (Window*)malloc(sizeof(window)))) {

		printf("Coudln't allocate a new window structure");
		return 0;
	}

	new_window->active = 1;
	new_window->pid = pid;
	new_window->flags = flags;
	new_window->x = 0;
	new_window->y = 0;
	new_window->w = width;
	new_window->h = height;
	new_window->title = (unsigned char*)0;
	new_window->frame_needs_redraw = 1;

	//Create a drawing context for the new window
	if (!(new_window->context = newBitmap(new_window->w, new_window->h))) {

		free((void*)new_window);
		printf("Couldn't allocate bitmap area for new window");
		return (window*)0;
	}

	bufsz = new_window->w * new_window->h;

	//Clear new window to white
	for (i = 0; i < bufsz; i++)
		new_window->context->data[i] = RGB(255, 255, 255);

	new_window->handle = next_handle++;

	if (mouse_window)
		List_pop(window_list, (void*)mouse_window);

	//De-activate the old active window
	if (temp_window = (window*)List_get_at(window_list, window_list->count - (mouse_window ? 2 : 1))) {

		temp_window->active = 0;
	}

	if (!List_add(window_list, (void*)new_window)){

		freeBitmap(new_window->context);
		free((void*)new_window);

		//re-activate the old active window
		if (temp_window)
			temp_window->active = 1;

		return (window*)0;
	}

	//Give the new window its initial decoration
	if (!(new_window->flags & WIN_UNDECORATED))
		drawFrame(new_window);

	drawWindow(new_window, 0);

	//Update the titlebar on the old active window 
	if (temp_window)
		drawTitlebar(temp_window, 1);

	if (mouse_window) {

		List_add(window_list, mouse_window);
		drawWindow(mouse_window, 0);
	}

	return new_window;
}