application: display mockup pinout on OLED screen

This commit is contained in:
King Kévin 2018-01-04 14:33:35 +01:00
parent b42d693bd0
commit 5f5f7c9558
1 changed files with 53 additions and 29 deletions

View File

@ -1017,6 +1017,59 @@ void main(void)
dac_set_trigger_source(DAC_CR_TSEL1_SW); // use software to trigger the voltage change
dac_set_trigger_source(DAC_CR_TSEL2_SW); // use software to trigger the voltage change
/*
printf("testing OLED screen\n");
i2c_master_setup(false);
const uint8_t oled_init[] = {
0x00, // control byte: continuous (multiple byes), command
0xae, // Set Display ON/OFF: OFF
// hardware configuration
0xa8, 0x3f, // Set Multiplex Ratio: 64
0xd3, 0x00, // Set Display Offset: 0
0xa1, // Set Segment Re-map: column address 0 is mapped to SEG127
0xc8, // Set COM Output Scan Direction: normal mode (RESET) Scan from COM[N-1] to COM[0]
0xda, 0x12, // Set COM Pins Hardware Configuration: Alternative COM pin configuration, Disable COM Left/Right remap
0x40, // Set Display Start Line: start line register from 0
// fundamental commands
0x81, 0xff, // Set Contrast Control: 256
0xa6, // Set Normal/Inverse Display: Normal display (RESET)
// Timing & Driving Scheme Setting
0xd5, 0xf0, // Set Display Clock Divide Ratio/Oscillator Frequency: Divide ratio=129, F_OSC=1
0xd9, 0x22, // Set Pre-charge Period: Phase 1=2 DCLK, Phase 2=2DCLK
0xdb, 0x20, // Set V_COMH Deselect Level: ~0.77xV_CC
// Charge Pump
0x8d, 0x14, // Charge Pump Setting: Enable Charge Pump
// Addressing Setting
0x20, 0x00 // Set Memory Addressing Mode: Horizontal Addressing Mode
};
i2c_master_write(0x3c, oled_init, LENGTH(oled_init), NULL, 0);
const uint8_t oled_entire_display_on[] = {
0x80, // control byte: no continuation, command
0xa5 // Entire Display ON: Entire display ON Output ignores RAM content
};
i2c_master_write(0x3c, oled_entire_display_on, LENGTH(oled_entire_display_on), NULL, 0);
const uint8_t oled_display_on[] = {
0x80, // control byte: no continuation, command
0xaf, // Set Display ON/OFF: ON
};
i2c_master_write(0x3c, oled_display_on, LENGTH(oled_display_on), NULL, 0);
sleep_ms(200);
const uint8_t oled_entire_display_ram[] = {
0x80, // control byte: no continuation, command
0xa4 // Entire Display ON: Resume to RAM content display
};
i2c_master_write(0x3c, oled_entire_display_ram, LENGTH(oled_entire_display_ram), NULL, 0);
const uint8_t oled_start_page[] = {
0x00, // control byte: continuous (multiple byes), command
0xb0, // Set Page Start Address for Page Addressing Mode: PAGE0
0x00, // Set Lower Column Start Address for Page Addressing Mode: 0
0x10 // Set Higher Column Start Address for Page Addressing Mode: 0
};
i2c_master_write(0x3c, oled_start_page, LENGTH(oled_start_page), NULL, 0);
const uint8_t oled_data[] = {0x40, 0, 254, 254, 0, 0, 0, 0, 0, 0, 254, 254, 0, 0, 224, 240, 56, 28, 14, 14, 28, 56, 240, 224, 0, 0, 254, 254, 134, 134, 134, 134, 134, 206, 252, 120, 0, 0, 6, 6, 6, 6, 254, 254, 6, 6, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 6, 6, 6, 254, 254, 6, 6, 6, 6, 0, 0, 30, 62, 112, 224, 192, 192, 224, 112, 62, 30, 0, 0, 254, 254, 134, 134, 134, 134, 134, 206, 252, 120, 0, 0, 30, 62, 112, 224, 192, 192, 224, 112, 62, 30, 0, 0, 31, 63, 112, 96, 96, 96, 96, 112, 63, 31, 0, 0, 127, 127, 6, 6, 6, 6, 6, 6, 127, 127, 0, 0, 127, 127, 1, 3, 7, 15, 29, 57, 112, 96, 0, 0, 0, 0, 0, 0, 127, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 127, 0, 0, 0, 0, 0, 0, 120, 124, 14, 7, 3, 3, 7, 14, 124, 120, 0, 0, 127, 127, 1, 3, 7, 15, 29, 57, 112, 96, 0, 0, 120, 124, 14, 7, 3, 3, 7, 14, 124, 120, 0, 255, 255, 3, 3, 3, 3, 11, 19, 35, 67, 131, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 131, 67, 35, 19, 11, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 132, 72, 48, 48, 72, 132, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 255, 17, 17, 49, 209, 14, 0, 0, 1, 1, 1, 255, 1, 1, 1, 0, 142, 17, 17, 33, 33, 198, 0, 0, 0, 0, 0, 0, 255, 17, 17, 49, 209, 14, 0, 0, 3, 204, 48, 48, 204, 3, 0, 0, 0, 0, 0, 0, 134, 1, 17, 17, 17, 238, 0, 0, 7, 56, 192, 0, 192, 56, 7, 0, 134, 1, 17, 17, 17, 238, 0, 0, 254, 1, 1, 33, 33, 230, 0, 0, 255, 6, 24, 96, 128, 255, 0, 0, 255, 1, 1, 1, 2, 252, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 64, 32, 16, 8, 4, 2, 1, 0, 0, 0, 0, 0, 0, 1, 2, 4, 8, 16, 32, 64, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 1, 2, 2, 2, 2, 1, 0, 0, 1, 2, 2, 2, 1, 3, 0, 0, 3, 0, 0, 0, 1, 3, 0, 0, 3, 2, 2, 2, 1, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 2, 4, 8, 16, 32, 64, 128, 0, 0, 0, 0, 0, 0, 128, 64, 32, 16, 8, 4, 2, 0, 0, 0, 128, 64, 64, 64, 64, 128, 0, 0, 64, 64, 64, 192, 64, 64, 64, 0, 128, 64, 64, 64, 64, 128, 0, 0, 0, 0, 0, 0, 64, 64, 64, 192, 64, 64, 64, 0, 192, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 192, 64, 64, 64, 64, 64, 0, 0, 192, 0, 0, 0, 0, 0, 192, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 64, 33, 18, 12, 12, 18, 33, 64, 128, 0, 0, 0, 0, 0, 0, 0, 0, 127, 128, 128, 128, 128, 97, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 99, 132, 132, 136, 136, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 0, 0, 0, 0, 192, 51, 12, 12, 51, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 195, 36, 24, 24, 36, 195, 0, 0, 1, 14, 48, 192, 48, 14, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 71, 132, 132, 132, 132, 120, 0, 0, 1, 14, 48, 192, 48, 14, 1, 0, 0, 0, 0, 0, 0, 255, 255, 255, 255, 192, 192, 192, 192, 208, 200, 196, 194, 193, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 193, 194, 196, 200, 208, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 255, 255};
i2c_master_write(0x3c, oled_data, LENGTH(oled_data), NULL, 0);
*/
// perform tests
printf("performing self-test, please follow instructions\n");
if (!test_self()) { // perform self-test
@ -1060,35 +1113,6 @@ void main(void)
wait_space();
*/
/*
printf("testing OLED screen\n");
i2c_master_setup(false);
const uint8_t oled_set_mux_ratio[] = {0x00, 0xa8, 0x3f};
i2c_master_write(0x3c, oled_set_mux_ratio, LENGTH(oled_set_mux_ratio), NULL, 0);
const uint8_t oled_set_display_offset[] = {0x00, 0xd3, 0x00};
i2c_master_write(0x3c, oled_set_display_offset, LENGTH(oled_set_display_offset), NULL, 0);
const uint8_t oled_set_start_line[] = {0x80, 0x40};
i2c_master_write(0x3c, oled_set_start_line, LENGTH(oled_set_start_line), NULL, 0);
const uint8_t oled_set_segment_remap[] = {0x80, 0xa0};
i2c_master_write(0x3c, oled_set_segment_remap, LENGTH(oled_set_segment_remap), NULL, 0);
const uint8_t oled_set_com_output_scan_direction[] = {0x80, 0xc0};
i2c_master_write(0x3c, oled_set_com_output_scan_direction, LENGTH(oled_set_com_output_scan_direction), NULL, 0);
const uint8_t oled_set_com_pins_hardware_configuration[] = {0x00, 0xda, 0x02};
i2c_master_write(0x3c, oled_set_com_pins_hardware_configuration, LENGTH(oled_set_com_pins_hardware_configuration), NULL, 0);
const uint8_t oled_set_contrast_control[] = {0x00, 0x81, 0x7f};
i2c_master_write(0x3c, oled_set_contrast_control, LENGTH(oled_set_contrast_control), NULL, 0);
const uint8_t oled_entire_display_on[] = {0x80, 0xa5};
i2c_master_write(0x3c, oled_entire_display_on, LENGTH(oled_entire_display_on), NULL, 0);
const uint8_t oled_normal_display[] = {0x80, 0xa6};
i2c_master_write(0x3c, oled_normal_display, LENGTH(oled_normal_display), NULL, 0);
const uint8_t oled_set_osc_frequency[] = {0x00, 0xd5, 0x80};
i2c_master_write(0x3c, oled_set_osc_frequency, LENGTH(oled_set_osc_frequency), NULL, 0);
const uint8_t oled_enable_charge_pump_regulator[] = {0x00, 0x8d, 0x14};
i2c_master_write(0x3c, oled_enable_charge_pump_regulator, LENGTH(oled_enable_charge_pump_regulator), NULL, 0);
const uint8_t oled_display_on[] = {0x80, 0xaf};
i2c_master_write(0x3c, oled_display_on, LENGTH(oled_display_on), NULL, 0);
*/
// main loop
printf("command input: ready\n");
bool action = false; // if an action has been performed don't go to sleep