Exemple #1
0
void displaySettings() {
	char mode_buf[32];
	snprintf(mode_buf, sizeof(mode_buf), "%s", "settings");

	/* TODO : Settings display
	 * We display all settings lines, highlighting the active row 
	 * Static display of settings, bitmapLine under active row
	 * 0,0  mode buffer
	 * 0,12 tcr buffer
	 * 0,24 flip buffer
	 * 0,36 
	 * Line at 0,(currentSetting * 13)
	 * */
	char item1[32];
	char item2[32];
	char item3[32];
	char item4[32];

	double tcr = ctx.settings.tcrValue * 100000;
	int cleanTCR = (int)tcr;
	snprintf(item1, sizeof(item1), "%s: %d", "TCR", cleanTCR);
	snprintf(item2, sizeof(item2), "%d", ctx.atomizer.resistance);

	int pos = ctx.settings.setPos * 12 + 10;

	Display_Clear();
	Display_PutText(0, 0, mode_buf, FONT_DEJAVU_8PT);
	Display_PutText(0, 12, item1, FONT_DEJAVU_8PT);
	Display_PutText(0, 24, item2, FONT_DEJAVU_8PT);
	Display_PutPixels(0, pos, bitmapLine, bitmapLineWidth, bitmapLineHeight);
	Display_Update();
}
Exemple #2
0
int main() {
	int i;

	// The virtual COM port is not initialized by default.
	// To initialize it, follow those steps:
	// 1) Unlock system control registers.
	SYS_UnlockReg();
	// 2) Initialize the virtual COM port.
	USB_VirtualCOM_Init();
	// 3) Lock system control registers.
	SYS_LockReg();

	// Display some text, just to know it's working
	Display_PutText(0, 0, "USB OK.", FONT_DEJAVU_8PT);
	Display_Update();

	while(1) {
		// Send string over the virtual COM port
		USB_VirtualCOM_SendString("Hello, USB!\r\n");

		// Wait 3 seconds
		for(i=0;i<30;i++) {
			Timer_DelayUs(100000);
		}
	}
}
Exemple #3
0
void Display_SSD_Init() {
	// Power on and initialize controller
	Display_SSD_isPowerOn = 1;
	if(Display_GetType() == DISPLAY_SSD1327) {
		Display_SSD1327_PowerOn();
		Display_SSD1327_SendInitCmds();
	}
	else {
		Display_SSD1306_PowerOn();
		Display_SSD1306_SendInitCmds();
	}

	if(Display_IsFlipped()) {
		Display_SSD_Flip();
	}

	// Update GDDRAM
	Display_Update();

	// Display ON
	Display_SSD_SetOn(1);

	// Delay 20ms
	Timer_DelayUs(20000);
}
Exemple #4
0
int main() {
	// Blit text
	Display_PutText(8, 56, "Hello,\nWorld.", FONT_DEJAVU_8PT);

	// Update display
	Display_Update();
}
Exemple #5
0
void Display_SSD_Init() {

	// Reset display controller
	// TODO: figure out PA.1 and PC.4
	PA1 = 1;
	PC4 = 1;
	Timer_DelayUs(1000);
	DISPLAY_SSD_RESET = 0;
	Timer_DelayUs(1000);
	DISPLAY_SSD_RESET = 1;
	Timer_DelayUs(1000);

	if(Display_GetType() == DISPLAY_SSD1327) {
		Display_SSD1327_SendInitCmds();
	}
	else {
		Display_SSD1306_SendInitCmds();
	}

	if(Display_IsFlipped()) {
		Display_SSD_Flip();
	}

	// Update GDDRAM
	Display_Update();

	// Display ON
	Display_SSD_SetOn(1);

	// Delay 20ms
	Timer_DelayUs(20000);
}
Exemple #6
0
int main() {
    //First map in the initrd
    ImportInitrd();

    Display_Initialize();

    int disp_cnt = Display_GetDisplayCount();

    DisplayInfo disp_info;
    Display_GetInfo(0, &disp_info);
    uint64_t disp_fd = Display_TryLockDisplay(0);

    void *file_loc = NULL;
    size_t file_size = 0;
    GetFile("wallpaper.png", &file_loc, &file_size);

    int img_w = 0;
    int img_h = 0;
    int img_p = 0;
    int res_len = 0;

    void *result = DecodePNGtoRGBA(file_loc, file_size, &img_w, &img_h, &img_p, &res_len);


    uint64_t buf_len = disp_info.pitch * disp_info.height;
    uint64_t vAddr = 0;
    uint64_t read_key = 0, write_key = 0;
    IO_AllocateBuffer(&buf_len,
                      &vAddr,
                      &read_key,
                      &write_key);

    uint8_t *display_addr = (uint8_t*)vAddr;
    uint8_t *src_img = (uint8_t*)result;
    /*
        for(int y = 0; y < img_h; y++) {
            for(int x = 0; x < img_w; x++) {

                display_addr[y * disp_info.pitch + (4 * x)] = src_img[y * img_p + (4 * x)];
                display_addr[y * disp_info.pitch + (4 * x) + 1] = src_img[y * img_p + (4 * x) + 1];
                display_addr[y * disp_info.pitch + (4 * x) + 2] = src_img[y * img_p + (4 * x) + 2];
                display_addr[y * disp_info.pitch + (4 * x) + 3] = src_img[y * img_p + (4 * x) + 3];

            }
        }
    */
    Display_Update(disp_fd, write_key, buf_len);

    Display_UnlockDisplay(disp_fd);

    //Wait until exit requested on power off
    while(1);
}
Exemple #7
0
void displayVW() {
	char mode_buf[3];
	char out_buf[5];
	char bat_buf[5];
	
	snprintf(mode_buf, sizeof(mode_buf), "%s", "vw");
	snprintf(out_buf, sizeof(out_buf), "%dw", ctx.settings.tW/1000);
	snprintf(bat_buf, sizeof(bat_buf), "%d%%", ctx.battery.percent);
	
	Display_Clear();
	Display_PutPixels(4, 2, bitmapBottle, bitmapBottleWidth, bitmapBottleHeight);
	Display_PutText(24, 0, mode_buf, FONT_DEJAVU_8PT);
	Display_PutPixels(0, 112, bitmapLine, bitmapLineWidth, bitmapLineHeight);
	Display_PutText(0, 116, out_buf, FONT_DEJAVU_8PT);
	Display_PutText(32, 116, bat_buf, FONT_DEJAVU_8PT);
	Display_Update();
}
Exemple #8
0
int main() {
	int hwVerMajor, hwVerMinor;
	char buffer[100];

	// Separate major/minor version
	hwVerMajor = Dataflash_info.hwVersion / 100;
	hwVerMinor = Dataflash_info.hwVersion % 100;

	// Build and blit text
	siprintf(buffer, "Hw: %d.%02d\n%s\nFlip: %d\nBoot: %s",
		hwVerMajor, hwVerMinor,
		Display_GetType() == DISPLAY_SSD1327 ? "SSD1327" : "SSD1306",
		Display_IsFlipped(),
		Dataflash_info.bootFlag == DATAFLASH_BOOTFLAG_LDROM ? "LD" : "AP");
	Display_PutText(0, 0, buffer, FONT_DEJAVU_8PT);

	// Update display
	Display_Update();
}
Exemple #9
0
int main() {
	uint8_t state;
	char buf[100];

	while(1) {
		// Build state report
		state = Button_GetState();
		sprintf(buf, "Mask: %02X\n\nFire: %d\nRight: %d\nLeft: %d",
			state,
			(state & BUTTON_MASK_FIRE) ? 1 : 0,
			(state & BUTTON_MASK_RIGHT) ? 1 : 0,
			(state & BUTTON_MASK_LEFT) ? 1 : 0);

		// Clear and blit text
		Display_Clear();
		Display_PutText(0, 0, buf, FONT_DEJAVU_8PT);
		Display_Update();
	}
}
Exemple #10
0
void displayFiring() {
	char temp_buf[12];
	char out_buf[5];
	snprintf(temp_buf, sizeof(temp_buf), "%dc", (int)ctx.coil.temp);
	snprintf(out_buf, sizeof(out_buf), "%dw",
			(ctx.atomizer.voltage * ctx.atomizer.current) / 1000000);

	Display_Clear();

	int lines;
	lines = numLines();
	for(int i = 0; i < lines; i += 2) {
		Display_PutPixels(0, i, bitmapLine, bitmapLineWidth, bitmapLineHeight);
	}

	Display_PutPixels(0, 112, bitmapLine, bitmapLineWidth, bitmapLineHeight);
	Display_PutText(0, 116, temp_buf, FONT_DEJAVU_8PT);
	Display_PutText(32, 116, out_buf, FONT_DEJAVU_8PT);
	Display_Update();
}
Exemple #11
0
// Main
int main() {
	// initial settings, will change to user interactive / eeprom
	ctx.settings.mode = 3;
	ctx.settings.maxCtrlWatts = 75000;
	ctx.settings.maxWatts = 75000;
	ctx.settings.minTemp = 60;
	ctx.settings.maxTemp = 300;
	ctx.settings.tcrValue = 0.00092;

	ctx.settings.tT = 248;
	ctx.settings.tW = 56000;

	ctx.settings.lockRes = false;
	ctx.settings.flip = false;
	ctx.settings.stealth = false;
	ctx.settings.lock = false;
	ctx.settings.timeout = 10;

	// init timers
	uint8_t timeTimer;
	timeTimer = Timer_CreateTimer(1, 1, incrementTime, 1);
	uint8_t loopTimer;
	loopTimer = Timer_CreateTimer(FPS, 1, readyLoop, 1);

	// init atomizer
	Atomizer_SetErrorLock(true);

	// main loop, rest is event handling
	while(1) {
		loop = 0;
		// collect runtime data
		collectData();

		// do controls
		doControls();

		if(ctx.state.firing) {
			displayFiring();
		} else {
			if(ctx.state.idleTimer < 20) {
				switch(ctx.settings.mode) {
					case 0: // settings
						displaySettings();
						break;
					case 1: // vw
						displayVW();
						break;
					case 2: // bp
						displayBP();
						break;
					case 3: // tc
						displayTC();
						break;
				}
			} else {
				// switch to low power mode
				Display_Clear();
				Display_Update();
				sleep();
			}
		}

		// waste time until loop refresh timer is ready
		while(loop == 0) {}
	}

	return 0;
}
Exemple #12
0
static void OnTimerDraw_ResetSettings(void)
{
    Display_Update();
}