mirror of
https://github.com/Spritetm/minimacplus.git
synced 2024-12-28 18:29:25 +00:00
Mipi display output!
This commit is contained in:
parent
c64c92a2e4
commit
bcf2bc85bc
@ -60,7 +60,7 @@ void app_main()
|
||||
err=esp_partition_mmap(part, 0, 128*1024, SPI_FLASH_MMAP_DATA, (const void**)&romdata, &hrom);
|
||||
if (err!=ESP_OK) printf("Couldn't map bootrom part!\n");
|
||||
printf("Starting emu...\n");
|
||||
xTaskCreatePinnedToCore(&mouseTask, "mouse", 6*1024, NULL, 6, NULL, 0);
|
||||
// xTaskCreatePinnedToCore(&mouseTask, "mouse", 6*1024, NULL, 6, NULL, 0);
|
||||
xTaskCreatePinnedToCore(&emuTask, "emu", 6*1024, NULL, 5, NULL, 0);
|
||||
}
|
||||
|
||||
|
221
components/tme-esp32/mipi_lcd.c
Normal file
221
components/tme-esp32/mipi_lcd.c
Normal file
@ -0,0 +1,221 @@
|
||||
/* SPI Master example
|
||||
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
|
||||
Unless required by applicable law or agreed to in writing, this
|
||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
||||
CONDITIONS OF ANY KIND, either express or implied.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_system.h"
|
||||
#include "driver/spi_master.h"
|
||||
#include "soc/gpio_struct.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_heap_alloc_caps.h"
|
||||
#include "mpumouse.h"
|
||||
#include "mouse.h"
|
||||
|
||||
|
||||
#include "mipi.h"
|
||||
#include "mipi_dsi.h"
|
||||
|
||||
typedef struct {
|
||||
uint8_t type;
|
||||
uint8_t addr;
|
||||
uint8_t len;
|
||||
uint8_t data[16];
|
||||
} DispPacket;
|
||||
|
||||
//Copied from the X163QLN01 appliation note.
|
||||
DispPacket initPackets[]={
|
||||
#if 0
|
||||
{0x39, 0xF0, 5, {0x55, 0x55, 0x55, 0x55, 0x55}},
|
||||
{0x39, 0xBD, 5, {0x01, 0x01, 0x01, 0x01, 0x01}},
|
||||
{0x39, 0xBE, 5, {0x01, 0x01, 0x01, 0x01, 0x01}},
|
||||
{0x39, 0xBF, 5, {0x01, 0x01, 0x01, 0x01, 0x01}},
|
||||
{0x39, 0xBB, 3, {0x07, 0x07, 0x07}},
|
||||
{0x39, 0xD0, 1, {0x00}},
|
||||
{0x39, 0xD1, 3, {0x00, 0x00, 0x00}},
|
||||
{0x39, 0xD2, 3, {0x00, 0x00, 0x00}},
|
||||
{0x39, 0xD3, 3, {0x00, 0x00, 0x00}},
|
||||
{0x39, 0xC7, 1, {0x40}},
|
||||
{0x39, 0xF0, 5, {0x55, 0x55, 0x55, 0x55, 0x55}},
|
||||
{0x15, 0xEB, 1, {0x02}},
|
||||
{0x15, 0xF5, 1, {0x10}},
|
||||
{0x39, 0xED, 8, {0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48}},
|
||||
{0x39, 0xC7, 8, {0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F}},
|
||||
{0x39, 0xFE, 2, {0x08, 0x08}},
|
||||
{0x39, 0xC3, 3, {0xF2, 0xF2, 0xF2}},
|
||||
{0x39, 0xE9, 3, {0x00, 0x00, 0x00}},
|
||||
{0x15, 0xCA, 1, {0x04}},
|
||||
{0x39, 0xF0, 5, {0x55, 0x55, 0x55, 0x55, 0x55}},
|
||||
{0x39, 0xB0, 3, {0x00, 0x00, 0x00}},
|
||||
{0x39, 0xB1, 3, {0x05, 0x05, 0x05}},
|
||||
{0x39, 0xB2, 3, {0x01, 0x01, 0x01}},
|
||||
{0x39, 0xB4, 3, {0x07, 0x07, 0x07}},
|
||||
{0x39, 0xB5, 3, {0x03, 0x03, 0x03}},
|
||||
{0x39, 0xB6, 3, {0x55, 0x55, 0x55}},
|
||||
{0x39, 0xB7, 3, {0x35, 0x35, 0x35}},
|
||||
{0x39, 0xB8, 3, {0x23, 0x23, 0x23}},
|
||||
{0x39, 0xB9, 3, {0x03, 0x03, 0x03}},
|
||||
{0x39, 0xBA, 3, {0x03, 0x03, 0x03}},
|
||||
{0x39, 0xBE, 3, {0x32, 0x32, 0x32}},
|
||||
{0x39, 0xC2, 12, {0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B}},
|
||||
{0x39, 0xCF, 7, {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}},
|
||||
{0x15, 0x35, 1, {0x00}},
|
||||
{0x15, 0x36, 1, {0x00}},
|
||||
{0x15, 0xC0, 1, {0x28}},
|
||||
{0x32, 0x00, 1, {0x00}},
|
||||
{0x15, 0x51, 1, {0x00}},
|
||||
{0x05, 0x11, 1, {0x00}},
|
||||
{0x05, 0x29, 1, {0x00}},
|
||||
#endif
|
||||
#if 0
|
||||
{0x39, 0xF0, 5, {0x55, 0x55, 0x55, 0x55, 0x55}},
|
||||
{0x39, 0xBD, 5, {0x01, 0x01, 0x01, 0x01, 0x01}},
|
||||
{0x39, 0xBE, 5, {0x01, 0x01, 0x01, 0x01, 0x01}},
|
||||
{0x39, 0xBF, 5, {0x01, 0x01, 0x01, 0x01, 0x01}},
|
||||
{0x39, 0xBB, 3, {0x07, 0x07, 0x07}},
|
||||
{0x39, 0xD0, 1, {0x00}},
|
||||
{0x39, 0xD1, 3, {0x00, 0x00, 0x00}},
|
||||
{0x39, 0xD2, 3, {0x00, 0x00, 0x00}},
|
||||
{0x39, 0xD3, 3, {0x00, 0x00, 0x00}},
|
||||
{0x39, 0xC7, 1, {0x40}},
|
||||
{0x39, 0xF0, 5, {0x55, 0x55, 0x55, 0x55, 0x55}},
|
||||
{0x15, 0xEB, 1, {0x02}},
|
||||
{0x15, 0xF5, 1, {0x10}},
|
||||
{0x39, 0xED, 8, {0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48}},
|
||||
{0x39, 0xC7, 8, {0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F}},
|
||||
{0x39, 0xFE, 2, {0x08, 0x08}},
|
||||
{0x39, 0xC3, 3, {0xF2, 0xF2, 0xF2}},
|
||||
{0x39, 0xE9, 3, {0x00, 0x00, 0x00}},
|
||||
{0x15, 0xCA, 1, {0x04}},
|
||||
{0x39, 0xF0, 5, {0x55, 0x55, 0x55, 0x55, 0x55}},
|
||||
{0x39, 0xB0, 3, {0x00, 0x00, 0x00}},
|
||||
{0x39, 0xB1, 3, {0x05, 0x05, 0x05}},
|
||||
{0x39, 0xB2, 3, {0x01, 0x01, 0x01}},
|
||||
{0x39, 0xB4, 3, {0x07, 0x07, 0x07}},
|
||||
{0x39, 0xB5, 3, {0x03, 0x03, 0x03}},
|
||||
{0x39, 0xB6, 3, {0x55, 0x55, 0x55}},
|
||||
{0x39, 0xB7, 3, {0x35, 0x35, 0x35}},
|
||||
{0x39, 0xB8, 3, {0x23, 0x23, 0x23}},
|
||||
{0x39, 0xB9, 3, {0x03, 0x03, 0x03}},
|
||||
{0x39, 0xBA, 3, {0x03, 0x03, 0x03}},
|
||||
{0x39, 0xBE, 3, {0x32, 0x32, 0x32}},
|
||||
{0x39, 0xC2, 12, {0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B}},
|
||||
{0x39, 0xCF, 7, {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}},
|
||||
{0x15, 0x35, 1, {0x00}},
|
||||
{0x15, 0x36, 1, {0x00}},
|
||||
{0x15, 0xC0, 1, {0x28}},
|
||||
{0x32, 0x00, 1, {0x00}},
|
||||
{0x15, 0x51, 1, {0x00}},
|
||||
{0x05, 0x11, 1, {0x00}},
|
||||
{0x05, 0x29, 1, {0x00}},
|
||||
#endif
|
||||
#if 1
|
||||
{0x39, 0xF0, 5, {0x55, 0xAA, 0x52, 0x08, 0x00}},
|
||||
{0x39, 0xBD, 5, {0x01, 0x90, 0x14, 0x14, 0x00}},
|
||||
{0x39, 0xBE, 5, {0x01, 0x90, 0x14, 0x14, 0x01}},
|
||||
{0x39, 0xBF, 5, {0x01, 0x90, 0x14, 0x14, 0x00}},
|
||||
{0x39, 0xBB, 3, {0x07, 0x07, 0x07}},
|
||||
{0x39, 0xC7, 1, {0x40}},
|
||||
{0x39, 0xF0, 5, {0x55, 0xAA, 0x52, 0x80, 0x02}},
|
||||
{0x39, 0xFE, 2, {0x08, 0x50}},
|
||||
{0x39, 0xC3, 3, {0xF2, 0x95, 0x04}},
|
||||
{0x15, 0xCA, 1, {0x04}},
|
||||
{0x39, 0xF0, 5, {0x55, 0xAA, 0x52, 0x08, 0x01}},
|
||||
{0x39, 0xB0, 3, {0x03, 0x03, 0x03}},
|
||||
{0x39, 0xB1, 3, {0x05, 0x05, 0x05}},
|
||||
{0x39, 0xB2, 3, {0x01, 0x01, 0x01}},
|
||||
{0x39, 0xB4, 3, {0x07, 0x07, 0x07}},
|
||||
{0x39, 0xB5, 3, {0x05, 0x05, 0x05}},
|
||||
{0x39, 0xB6, 3, {0x53, 0x53, 0x53}},
|
||||
{0x39, 0xB7, 3, {0x33, 0x33, 0x33}},
|
||||
{0x39, 0xB8, 3, {0x23, 0x23, 0x23}},
|
||||
{0x39, 0xB9, 3, {0x03, 0x03, 0x03}},
|
||||
{0x39, 0xBA, 3, {0x13, 0x13, 0x13}},
|
||||
{0x39, 0xBE, 3, {0x22, 0x30, 0x70}},
|
||||
{0x39, 0xCF, 7, {0xFF, 0xD4, 0x95, 0xEF, 0x4F, 0x00, 0x04}},
|
||||
{0x15, 0x35, 1, {0x01}}, //
|
||||
{0x15, 0x36, 1, {0x00}}, //
|
||||
{0x15, 0xC0, 1, {0x20}}, //
|
||||
{0x39, 0xC2, 6, {0x17, 0x17, 0x17, 0x17, 0x17, 0x0B}},
|
||||
{0x32, 0, 0, {0}},
|
||||
{0x05, 0x11, 1, {0x00}}, //exit_sleep_mode
|
||||
{0x05, 0x29, 1, {0x00}}, //turn display on
|
||||
#endif
|
||||
{0x15, 0x3A, 1, {0x55}}, //16-bit mode
|
||||
// {0x29, 0x2B, 4, {0x00, 0x00, 0x00, 0xEF}},
|
||||
{0,0,0,{0}}
|
||||
};
|
||||
|
||||
|
||||
volatile static uint8_t *currFbPtr=NULL;
|
||||
SemaphoreHandle_t dispSem = NULL;
|
||||
|
||||
void IRAM_ATTR displayTask(void *arg) {
|
||||
|
||||
mipiInit();
|
||||
for (int i=0; initPackets[i].type!=0; i++) {
|
||||
if (initPackets[i].type==0x39 || initPackets[i].type==0x29) {
|
||||
uint8_t data[17];
|
||||
data[0]=initPackets[i].addr;
|
||||
memcpy(data+1, initPackets[i].data, 16);
|
||||
mipiDsiSendLong(initPackets[i].type, data, initPackets[i].len+1);
|
||||
} else {
|
||||
uint8_t data[2]={initPackets[i].addr, initPackets[i].data[0]};
|
||||
mipiDsiSendShort(initPackets[i].type, data, initPackets[i].len+1);
|
||||
if (initPackets[i].type==5) vTaskDelay(300/portTICK_RATE_MS);
|
||||
}
|
||||
}
|
||||
|
||||
printf("Inited.\n");
|
||||
uint8_t img[641];
|
||||
|
||||
while(1) {
|
||||
xSemaphoreTake(dispSem, portMAX_DELAY);
|
||||
uint8_t *myData=(uint8_t*)currFbPtr;
|
||||
uint8_t img[641];
|
||||
img[0]=0x2c;
|
||||
for (int j=0; j<320; j++) {
|
||||
uint8_t *p=&img[1];
|
||||
for (int i=0; i<320; i++) {
|
||||
if (myData[i/8]&(1<<(7-(i&7)))) {
|
||||
*p++=0;
|
||||
*p++=0;
|
||||
} else {
|
||||
*p++=0xFF;
|
||||
*p++=0xFF;
|
||||
}
|
||||
}
|
||||
mipiDsiSendLong(0x39, img, sizeof(img)+4);
|
||||
img[0]=0x3c;
|
||||
myData+=(512/8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void dispDraw(uint8_t *mem) {
|
||||
int dx, dy, btn;
|
||||
currFbPtr=mem;
|
||||
xSemaphoreGive(dispSem);
|
||||
// mpuMouseGetDxDyBtn(&dx, &dy, &btn);
|
||||
// mouseMove(dx, dy, btn);
|
||||
}
|
||||
|
||||
|
||||
void dispInit() {
|
||||
printf("spi_lcd_init()\n");
|
||||
dispSem=xSemaphoreCreateBinary();
|
||||
#if CONFIG_FREERTOS_UNICORE
|
||||
xTaskCreatePinnedToCore(&displayTask, "display", 3000, NULL, 5, NULL, 0);
|
||||
#else
|
||||
xTaskCreatePinnedToCore(&displayTask, "display", 3000, NULL, 5, NULL, 1);
|
||||
#endif
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
#if 0
|
||||
/* SPI Master example
|
||||
|
||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||
@ -309,3 +310,4 @@ void dispInit() {
|
||||
xTaskCreatePinnedToCore(&displayTask, "display", 3000, NULL, 6, NULL, 1);
|
||||
#endif
|
||||
}
|
||||
#endif
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#python /home/jeroen/esp8266/esp32/esp-idf/bin/esptool.py --chip esp32 --port "/dev/ttyUSB0" --baud 115200 write_flash -z -fs 32m 0x100000 doom1-cut.wad
|
||||
python /home/jeroen/esp8266/esp32/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port "/dev/ttyUSB1" --baud $((921600/2)) --before default_reset --after hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size detect 0x120000 $1
|
||||
python /home/jeroen/esp8266/esp32/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port "/dev/ttyUSB0" --baud $((921600/2)) --before default_reset --after hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size detect 0x120000 $1
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
#python /home/jeroen/esp8266/esp32/esp-idf/bin/esptool.py --chip esp32 --port "/dev/ttyUSB0" --baud 115200 write_flash -z -fs 32m 0x100000 doom1-cut.wad
|
||||
#python /home/jeroen/esp8266/esp32/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port "/dev/ttyUSB1" --baud $((921600/2)) --before default_reset --after hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size detect 0x100000 rom.bin
|
||||
python /home/jeroen/esp8266/esp32/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port "/dev/ttyUSB1" --baud $((921600/2)) --before default_reset --after hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size detect 0x100000 rom320240.bin
|
||||
python /home/jeroen/esp8266/esp32/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port "/dev/ttyUSB0" --baud $((921600/2)) --before default_reset --after hard_reset write_flash --flash_mode dio --flash_freq 40m --flash_size detect 0x100000 rom320240.bin
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user