Esempio n. 1
0
bool keyframe_animate_backlight_color(keyframe_animation_t* animation, visualizer_state_t* state) {
    int frame_length = animation->frame_lengths[animation->current_frame];
    int current_pos = frame_length - animation->time_left_in_frame;
    uint8_t t_h = LCD_HUE(state->target_lcd_color);
    uint8_t t_s = LCD_SAT(state->target_lcd_color);
    uint8_t t_i = LCD_INT(state->target_lcd_color);
    uint8_t p_h = LCD_HUE(state->prev_lcd_color);
    uint8_t p_s = LCD_SAT(state->prev_lcd_color);
    uint8_t p_i = LCD_INT(state->prev_lcd_color);

    uint8_t d_h1 = t_h - p_h; //Modulo arithmetic since we want to wrap around
    int d_h2 = t_h - p_h;
    // Chose the shortest way around
    int d_h = abs(d_h2) < d_h1 ? d_h2 : d_h1;
    int d_s = t_s - p_s;
    int d_i = t_i - p_i;

    int hue = (d_h * current_pos) / frame_length;
    int sat = (d_s * current_pos) / frame_length;
    int intensity = (d_i * current_pos) / frame_length;
    //dprintf("%X -> %X = %X\n", p_h, t_h, hue);
    hue += p_h;
    sat += p_s;
    intensity += p_i;
    state->current_lcd_color = LCD_COLOR(hue, sat, intensity);
    lcd_backlight_color(
            LCD_HUE(state->current_lcd_color),
            LCD_SAT(state->current_lcd_color),
            LCD_INT(state->current_lcd_color));

    return true;
}
Esempio n. 2
0
// This function should be implemented by the keymap visualizer
// Don't change anything else than state->target_lcd_color and state->layer_text as that's the only thing
// that the simple_visualizer assumes that you are updating
// Also make sure that the buffer passed to state->layer_text remains valid until the previous animation is
// stopped. This can be done by either double buffering it or by using constant strings
static void get_visualizer_layer_and_color(visualizer_state_t* state) {
    uint8_t saturation = 60;
    if (state->status.leds & (1u << USB_LED_CAPS_LOCK)) {
        saturation = 255;
    }
    if (state->status.layer & 0x80) {
        state->target_lcd_color = LCD_COLOR(0, 255, 60);
        state->layer_text = "Game Arrow";
    } else if (state->status.layer & 0x40) {
        state->target_lcd_color = LCD_COLOR(0, 255, 60);
        state->layer_text = "Game";
    } else if (state->status.layer & 0x20) {
        state->target_lcd_color = LCD_COLOR(140, 100, 60);
        state->layer_text = "Movement";
    } else if (state->status.layer & 0x10) {
        state->target_lcd_color = LCD_COLOR(0, saturation, 0xFF);
        state->layer_text = "Media";
    } else if (state->status.layer & 0x8) {
        state->target_lcd_color = LCD_COLOR(168, saturation, 0xFF);
        state->layer_text = "Symbol";
    } else if (state->status.layer & 0x2 || state->status.layer & 0x4) {
        state->target_lcd_color = LCD_COLOR(216, 90, 0xFF);
        state->layer_text = "Code";
    } else {
        state->target_lcd_color = LCD_COLOR(84, saturation, 0xFF);
        state->layer_text = "Default";
    }
}
Esempio n. 3
0
// This function should be implemented by the keymap visualizer
// Don't change anything else than state->target_lcd_color and state->layer_text as that's the only thing
// that the simple_visualizer assumes that you are updating
// Also make sure that the buffer passed to state->layer_text remains valid until the previous animation is
// stopped. This can be done by either double buffering it or by using constant strings
static void get_visualizer_layer_and_color(visualizer_state_t* state) {
    uint8_t saturation = 60;
    if (state->status.leds & (1u << USB_LED_CAPS_LOCK)) {
        saturation = 255;
    }
    if (state->status.layer & 0x4) {
        state->target_lcd_color = LCD_COLOR(0, saturation, 0xFF);
        state->layer_text = "Media & Mouse";
    }
    else if (state->status.layer & 0x2) {
        state->target_lcd_color = LCD_COLOR(168, saturation, 0xFF);
        state->layer_text = "Symbol";
    }
    else {
        state->target_lcd_color = LCD_COLOR(84, saturation, 0xFF);
        state->layer_text = "Default";
    }
}
Esempio n. 4
0
	lcd_data_write_data(vertical_scrolling_pointer & 0xff);
}
/*
uint_fast16_t lcd_get_scanline() {
	lcd_data_write_command(0x45);
	lcd_data_read();
	const uint_fast8_t gts_h = lcd_data_read() & 0x3;
	const uint_fast8_t gts_l = lcd_data_read() & 0xff;
	return (gts_h << 8) | gts_l;
}
*/
void lcd_frame_sync() {
	portapack_lcd_frame_sync();
}

const lcd_color_t color_black = LCD_COLOR(0, 0, 0);
const lcd_color_t color_blue  = LCD_COLOR(0, 0, 255);
const lcd_color_t color_red   = LCD_COLOR(255, 0, 0);
const lcd_color_t color_white = LCD_COLOR(255, 255, 255);

const lcd_glyph_t* lcd_get_glyph(const lcd_t* const lcd, const char c) {
	const lcd_font_t* const font = lcd->font;
	if( (c >= font->glyph_table_start) && (c <= font->glyph_table_end) ) {
		return &font->glyph_table[c - font->glyph_table_start];
	} else {
		return &font->glyph_table[0];
	}
}

static uint_fast16_t lcd_string_width(
	const lcd_t* const lcd,
Esempio n. 5
0
lcd_color_t lcdColor(uint8_t r, uint8_t g, uint8_t b)
{
    return LCD_COLOR(r, g, b);
}
Esempio n. 6
0
/**
 * @brief	Main program
 * @param	None
 * @retval	None: no exit point
 */
int main(void)
{
	uint16_t u16Menu = 0;
	uint16_t uVal;

	NVIC_Relocate();

	/* Initialize SysTick - 1msec resolution */
	SysTick_Config(SystemCoreClock / 1000);

	/* Initialize main board peripherals */
	MBD_Init();
	printf("miniSTM32 mainboard initialized.\n");

	/* Initialize LCD support */
	LCD_Init();
	LCD_DisplayOn();
	printf("LCD initialized.\n");
	LCD_BacklightOn();
	printf("\n\nPress the button to start demo.\n\n");

	while (1) 
	{
		/* main menu controlled by pushbutton interrupt */
		if( uIRQFlag == MAIN_BTN_EXTI_LINE ) {

			/* clear button interrupt flag */
			uIRQFlag = 0;

			/* droid family fonts */

			if( u16Menu == MENU_FONT_TEST1 ) {
				uVal = START_Y;
				LCD_Clear(LCD_COLOR_BLACK);
				LCD_SetFGColor(LCD_COLOR_YELLOW);
				LCD_SetBGColor(LCD_COLOR(40,40,80));

			/* 2.4inch LCD has not enough space to draw long string */
			#if defined(LCD_QD024CPS25)

				LCD_SetFont(&DroidSans_18);
				LCD_DisplayStringLine(START_X, uVal, "Droid Sans 18 point");

				uVal += DroidSans_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_Bold_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Sans Bold 18 pt");

				uVal += DroidSans_Bold_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSerif_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Serif 18 point");

				uVal += DroidSerif_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSerif_Bold_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Serif Bold 18 pt");

				uVal += DroidSerif_Bold_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSerif_Italic_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Serif Italic 18");

			#else

				LCD_SetFont(&DroidSans_18);
				LCD_DisplayStringLine(START_X, uVal, "Droid Sans 18 point");

				uVal += DroidSans_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_Bold_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Sans Bold 18 point");

				uVal += DroidSans_Bold_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSerif_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Serif 18 point");

				uVal += DroidSerif_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSerif_Bold_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Serif Bold 18 point");

				uVal += DroidSerif_Bold_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSerif_Italic_18); 
				LCD_DisplayStringLine(START_X, uVal, "Droid Serif Italic 18 point");

			#endif
			}

			/* liberation family fonts, federant font */

			else if( u16Menu == MENU_FONT_TEST2 ) {
				uVal = START_Y;
				LCD_Clear(LCD_COLOR_BLACK);
				LCD_SetFGColor(LCD_COLOR_YELLOW);
				LCD_SetBGColor(LCD_COLOR(40,40,80));

			/* 2.4inch LCD has not enough space to draw long string */
			#if defined(LCD_QD024CPS25)

				LCD_SetFont(&LiberationSans_18);
				LCD_DisplayStringLine(START_X, uVal, "Liberation Sans 18 point");

				uVal += LiberationSans_18.Height + LINE_SEP;
				LCD_SetFont(&LiberationSerif_18); 
				LCD_DisplayStringLine(START_X, uVal, "Liberation Serif 18 point");

				uVal += LiberationSerif_18.Height + LINE_SEP;
				LCD_SetFont(&LiberationSerif_Italic_18); 
				LCD_DisplayStringLine(START_X, uVal, "Liberation Serif Italic 18");

				uVal += LiberationSerif_Italic_18.Height + LINE_SEP;
				LCD_SetFont(&Federant_18); 
				LCD_DisplayStringLine(START_X, uVal, "Federant 18 point");

			#else

				LCD_SetFont(&LiberationSans_18);
				LCD_DisplayStringLine(START_X, uVal, "Liberation Sans 18 point");

				uVal += LiberationSans_18.Height + LINE_SEP;
				LCD_SetFont(&LiberationSerif_18); 
				LCD_DisplayStringLine(START_X, uVal, "Liberation Serif 18 point");

				uVal += LiberationSerif_18.Height + LINE_SEP;
				LCD_SetFont(&LiberationSerif_Italic_18); 
				LCD_DisplayStringLine(START_X, uVal, "Liberation Serif Italic 18 point");

				uVal += LiberationSerif_Italic_18.Height + LINE_SEP;
				LCD_SetFont(&Federant_18); 
				LCD_DisplayStringLine(START_X, uVal, "Federant 18 point");

			#endif
			}

			/* Ubuntu family fonts */

			else if( u16Menu == MENU_FONT_TEST3 ) {
				uVal = START_Y;
				LCD_Clear(LCD_COLOR_BLACK);
				LCD_SetFGColor(LCD_COLOR_YELLOW);
				LCD_SetBGColor(LCD_COLOR(40,40,80));
			
			/* 2.4inch LCD has not enough space to draw long string */
			#if defined(LCD_QD024CPS25)

				LCD_SetFont(&Ubuntu_18);
				LCD_DisplayStringLine(START_X, uVal, "Ubuntu 18 point");

				uVal += Ubuntu_18.Height + LINE_SEP;
				LCD_SetFont(&Ubuntu_Bold_18); 
				LCD_DisplayStringLine(START_X, uVal, "Ubuntu Bold 18 point");

				uVal += Ubuntu_Bold_18.Height + LINE_SEP;
				LCD_SetFont(&Ubuntu_Italic_18); 
				LCD_DisplayStringLine(START_X, uVal, "Ubuntu Italic 18");

			#else

				LCD_SetFont(&Ubuntu_18);
				LCD_DisplayStringLine(START_X, uVal, "Ubuntu 18 point");

				uVal += Ubuntu_18.Height + LINE_SEP;
				LCD_SetFont(&Ubuntu_Bold_18); 
				LCD_DisplayStringLine(START_X, uVal, "Ubuntu Bold 18 point");

				uVal += Ubuntu_Bold_18.Height + LINE_SEP;
				LCD_SetFont(&Ubuntu_Italic_18); 
				LCD_DisplayStringLine(START_X, uVal, "Ubuntu Italic 18 point");

			#endif
			}

			/* various size of droid sans */

			else if( u16Menu == MENU_FONT_TEST4 ) {
				uVal = START_Y;
				LCD_Clear(LCD_COLOR_BLACK);
				LCD_SetFGColor(LCD_COLOR_YELLOW);
				LCD_SetBGColor(LCD_COLOR(40,40,80));

				LCD_SetFont(&DroidSans_10);
				LCD_DisplayStringLine(START_X, uVal, "DroidSans 10 point");

				uVal += DroidSans_10.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_12); 
				LCD_DisplayStringLine(START_X, uVal, "DroidSans 12 point");

				uVal += DroidSans_12.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_14); 
				LCD_DisplayStringLine(START_X, uVal, "DroidSans 14 point");

				uVal += DroidSans_14.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_16); 
				LCD_DisplayStringLine(START_X, uVal, "DroidSans 16 point");

				uVal += DroidSans_16.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_18); 
				LCD_DisplayStringLine(START_X, uVal, "DroidSans 18 point");

				uVal += DroidSans_18.Height + LINE_SEP;
				LCD_SetFont(&DroidSans_20); 
				LCD_DisplayStringLine(START_X, uVal, "DroidSans 20 point");

			}

			/* at the end of menu, restart all over */
			if( ++u16Menu == MENU_END )
			{
				printf("\n\nEnd of Demo: Press the button to restart... \n\n\n");
				u16Menu = 0;
			}

		}

		/* usual household routine goes here */
		{
		}
	}
}