Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
peng-zhihui committed Jul 31, 2022
1 parent 1a841c3 commit bf764fe
Show file tree
Hide file tree
Showing 544 changed files with 694,241 additions and 1 deletion.
1 change: 1 addition & 0 deletions 1.Hardware/工程链接.txt
@@ -0,0 +1 @@
https://oshwhub.com/pengzhihui/helloword-smart-keyboard
275 changes: 275 additions & 0 deletions 2.Firmware/HelloWord-Dynamic-fw/.cproject

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions 2.Firmware/HelloWord-Dynamic-fw/.gitignore
@@ -0,0 +1 @@
cmake-build-*
2 changes: 2 additions & 0 deletions 2.Firmware/HelloWord-Dynamic-fw/.idea/REF-STM32F4-fw.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions 2.Firmware/HelloWord-Dynamic-fw/.idea/deployment.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions 2.Firmware/HelloWord-Dynamic-fw/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions 2.Firmware/HelloWord-Dynamic-fw/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions 2.Firmware/HelloWord-Dynamic-fw/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions 2.Firmware/HelloWord-Dynamic-fw/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

309 changes: 309 additions & 0 deletions 2.Firmware/HelloWord-Dynamic-fw/.idea/workspace.xml

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions 2.Firmware/HelloWord-Dynamic-fw/.mxproject

Large diffs are not rendered by default.

86 changes: 86 additions & 0 deletions 2.Firmware/HelloWord-Dynamic-fw/.project
@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>HelloWord-Dynamic-fw</name>
<comment />
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>fr.ac6.mcu.ide.core.MCUProjectNature</nature>
</natures>
<linkedResources>

<link>
<name>FreeRTOS/croutine.c</name>
<type>1</type>
<location>PARENT-2-PROJECT_LOC/Middlewares/Third_Party/FreeRTOS/Source/croutine.c</location>
</link><link>
<name>FreeRTOS/event_groups.c</name>
<type>1</type>
<location>PARENT-2-PROJECT_LOC/Middlewares/Third_Party/FreeRTOS/Source/event_groups.c</location>
</link><link>
<name>FreeRTOS/list.c</name>
<type>1</type>
<location>PARENT-2-PROJECT_LOC/Middlewares/Third_Party/FreeRTOS/Source/list.c</location>
</link><link>
<name>FreeRTOS/queue.c</name>
<type>1</type>
<location>PARENT-2-PROJECT_LOC/Middlewares/Third_Party/FreeRTOS/Source/queue.c</location>
</link><link>
<name>FreeRTOS/stream_buffer.c</name>
<type>1</type>
<location>PARENT-2-PROJECT_LOC/Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c</location>
</link><link>
<name>FreeRTOS/tasks.c</name>
<type>1</type>
<location>PARENT-2-PROJECT_LOC/Middlewares/Third_Party/FreeRTOS/Source/tasks.c</location>
</link><link>
<name>FreeRTOS/timers.c</name>
<type>1</type>
<location>PARENT-2-PROJECT_LOC/Middlewares/Third_Party/FreeRTOS/Source/timers.c</location>
</link><link>
<name>FreeRTOS/cmsis_os2.c</name>
<type>1</type>
<location>PARENT-2-PROJECT_LOC/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c</location>
</link><link>
<name>FreeRTOS/heap_4.c</name>
<type>1</type>
<location>PARENT-2-PROJECT_LOC/Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c</location>
</link><link>
<name>FreeRTOS/port.c</name>
<type>1</type>
<location>PARENT-2-PROJECT_LOC/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c</location>
</link><link>
<name>USB_Device_Library/usbd_core.c</name>
<type>1</type>
<location>PARENT-2-PROJECT_LOC/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c</location>
</link><link>
<name>USB_Device_Library/usbd_ctlreq.c</name>
<type>1</type>
<location>PARENT-2-PROJECT_LOC/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c</location>
</link><link>
<name>USB_Device_Library/usbd_ioreq.c</name>
<type>1</type>
<location>PARENT-2-PROJECT_LOC/Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c</location>
</link><link>
<name>USB_Device_Library/usbd_cdc.c</name>
<type>1</type>
<location>PARENT-2-PROJECT_LOC/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c</location>
</link></linkedResources>
</projectDescription>
111 changes: 111 additions & 0 deletions 2.Firmware/HelloWord-Dynamic-fw/BSP/eink/eink_290_bw.cpp
@@ -0,0 +1,111 @@
#include <cstdio>
#include "eink_290_bw.h"
#include "pgmspace.h"
#include "stm32f4xx_hal.h"
#include "spi.h"


uint8_t Eink290BW::buffer[EPD_HEIGHT * EPD_WIDTH / 8];

void Eink290BW::Init()
{
HAL_GPIO_WritePin(EINK_RST_GPIO_Port, EINK_RST_Pin, GPIO_PIN_RESET);
HAL_Delay(200);
HAL_GPIO_WritePin(EINK_RST_GPIO_Port, EINK_RST_Pin, GPIO_PIN_SET);

WaitUntilIdle();
SendCommand(SW_RESET); // soft reset
WaitUntilIdle();

SendCommand(0x74); //set analog block control
SendData(0x54);
SendCommand(0x7E); //set digital block control
SendData(0x3B);

SendCommand(DRIVER_OUTPUT_CONTROL); //Driver output control
SendData(0x27);
SendData(0x01);
SendData(0x00);

SendCommand(DATA_ENTRY_MODE_SETTING); //data entry mode
SendData(0x01);

SendCommand(SET_RAM_X_ADDRESS_START_END_POSITION); //set Ram-X address start/end position
SendData(0x00);
SendData(0x0F); //0x0F-->(15+1)*8=128

SendCommand(SET_RAM_Y_ADDRESS_START_END_POSITION); //set Ram-Y address start/end position
SendData(0x27); //0x0127-->(295+1)=296
SendData(0x01);
SendData(0x00);
SendData(0x00);
SendCommand(BORDER_WAVEFORM_CONTROL); //set border
SendData(0x01);

SendCommand(0x18); // use the internal temperature sensor
SendData(0x80);


SendCommand(DISPLAY_UPDATE_CONTROL_2);
SendData(0xB1);
SendCommand(MASTER_ACTIVATION);

SendCommand(SET_RAM_X_ADDRESS_COUNTER);
SendData(0x00);
SendCommand(SET_RAM_Y_ADDRESS_COUNTER);
SendData(0x27);
SendData(0x01);
WaitUntilIdle();
printf("e-Paper init OK!");
}

void Eink290BW::DrawBitmap(const unsigned char* datas)
{
SendCommand(WRITE_RAM); //write RAM for black(0)/white (1)

for (int i = 0; i < SCREEN_BUFFER_SIZE; i++)
SendData(PGM_READ_BYTES(&datas[i]));
}

void Eink290BW::Update()
{
SendCommand(DISPLAY_UPDATE_CONTROL_1);
SendData(0x40);

SendCommand(DISPLAY_UPDATE_CONTROL_2);
SendData(0xC7);
SendCommand(MASTER_ACTIVATION);
WaitUntilIdle();
}

void Eink290BW::DeepSleep()
{
SendCommand(0x10); //enter deep sleep
SendData(0x01);
}


void Eink290BW::SendCommand(unsigned char command)
{
HAL_GPIO_WritePin(EINK_DC_GPIO_Port, EINK_DC_Pin, GPIO_PIN_RESET);
SpiTransfer(command);
}

void Eink290BW::SendData(unsigned char data)
{
HAL_GPIO_WritePin(EINK_DC_GPIO_Port, EINK_DC_Pin, GPIO_PIN_SET);
SpiTransfer(data);
}

void Eink290BW::WaitUntilIdle()
{
while (HAL_GPIO_ReadPin(EINK_BUSY_GPIO_Port, EINK_BUSY_Pin) == GPIO_PIN_SET)
HAL_Delay(100);
}

void Eink290BW::SpiTransfer(unsigned char data)
{
HAL_GPIO_WritePin(EINK_CS_GPIO_Port, EINK_CS_Pin, GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi2, &data, 1, 5);
HAL_GPIO_WritePin(EINK_CS_GPIO_Port, EINK_CS_Pin, GPIO_PIN_SET);
}
53 changes: 53 additions & 0 deletions 2.Firmware/HelloWord-Dynamic-fw/BSP/eink/eink_290_bw.h
@@ -0,0 +1,53 @@
#ifndef __DEPG0290BxS75AFxX_BW_H__
#define __DEPG0290BxS75AFxX_BW_H__

/* EPD commands */
#define DRIVER_OUTPUT_CONTROL 0x01
#define BOOSTER_SOFT_START_CONTROL 0x0C
#define GATE_SCAN_START_POSITION 0x0F
#define DEEP_SLEEP_MODE 0x10
#define DATA_ENTRY_MODE_SETTING 0x11
#define SW_RESET 0x12
#define TEMPERATURE_SENSOR_CONTROL 0x1A
#define MASTER_ACTIVATION 0x20
#define DISPLAY_UPDATE_CONTROL_1 0x21
#define DISPLAY_UPDATE_CONTROL_2 0x22
#define WRITE_RAM 0x24
#define WRITE_VCOM_REGISTER 0x2C
#define WRITE_LUT_REGISTER 0x32
#define SET_DUMMY_LINE_PERIOD 0x3A
#define SET_GATE_TIME 0x3B
#define BORDER_WAVEFORM_CONTROL 0x3C
#define SET_RAM_X_ADDRESS_START_END_POSITION 0x44
#define SET_RAM_Y_ADDRESS_START_END_POSITION 0x45
#define SET_RAM_X_ADDRESS_COUNTER 0x4E
#define SET_RAM_Y_ADDRESS_COUNTER 0x4F
#define TERMINATE_FRAME_READ_WRITE 0xFF
/* Display resolution */
#define EPD_WIDTH 128
#define EPD_HEIGHT 296
#define SCREEN_BUFFER_SIZE (EPD_WIDTH * EPD_HEIGHT / 8)


class Eink290BW
{
public:
Eink290BW()
= default;

void Init();
void Update();
void DeepSleep();
void DrawBitmap(const unsigned char* datas);

static uint8_t buffer[EPD_HEIGHT * EPD_WIDTH / 8];


private:
void SendCommand(unsigned char command);
void SendData(unsigned char data);
void WaitUntilIdle();
void SpiTransfer(unsigned char data);
};

#endif

0 comments on commit bf764fe

Please sign in to comment.