Skip to content

Commit

Permalink
Tons of features
Browse files Browse the repository at this point in the history
View release 5.25.24
  • Loading branch information
KaiyoFox authored May 25, 2024
1 parent 4bede96 commit d2a4063
Show file tree
Hide file tree
Showing 47 changed files with 12,366 additions and 41,731 deletions.
122 changes: 61 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
# RP2040 Smartwatch

The RP2040 Smartwatch is a customizable wearable device powered by the Raspberry Pi RP2040 microcontroller. This README provides information on how to flash the firmware and wire the required components.

## Flashing Instructions

To flash the firmware onto the RP2040 Smartwatch, follow these steps:

1. Hold down the **Reset** button.
2. While holding down **Reset**, also hold down the **Boot** button.
3. Release the **Reset** button.

This will put the device into firmware flash mode, allowing you to upload the desired firmware.

### Firmware Files

- **UF2 File (RP2040):** UF2 file for the RP2040 microcontroller can be found in the [Releases section](https://github.com/KaiyoFox/waveshare1.28-rp2040-smartwatch/releases/latest). This file is used for flashing the RP2040.
- **Seeed.ino File (Seeed Xiao):** This file is used for flashing the Seeed Xiao and can be found in the repository.

## Required Components

### RP2040 Touch LCD 1.28" Display

The RP2040 Smartwatch utilizes the Waveshare RP2040 Touch LCD 1.28" round display. You can find more information and purchase the display from [Waveshare](https://www.waveshare.com/rp2040-touch-lcd-1.28.htm).

### Seeed Xiao BLE nRF52840

The Seeed Xiao BLE nRF52840 is used for its Bluetooth capabilities. You can find more information and purchase the Seeed Xiao BLE from [Seeed Studio](https://www.seeedstudio.com/Seeed-XIAO-BLE-nRF52840-p-5201.html).

## Wiring Diagram

| RP2040 Pin | Seeed Pin |
|------------|-----------|
| GND | GND |
| VSYS | 3V3 |
| Run | Unused |
| Boot | Unused |
| GND2 | Connect to GPIO 26 on RP2040 via a 100k resistor and button |
| ADC_AVDD | Other end of button |
| GPIO 16 | D5 (Seeed) |
| GPIO 17 | D4 (Seeed) |
| GPIO 18 | D3 (Seeed) |
| GPIO 26 | Connect to 100k resistor that is on GND2 |
| GPIO 27 | D0 (Seeed) |
| GPIO 28 | D1 (Seeed) |

Note: On the Seeed Xiao, D2 is unused and D7 - D10 are also unused.

## Flashing the Seeed Xiao

Please refer to the [Seeed Studio Wiki](https://wiki.seeedstudio.com/XIAO_BLE/) for instructions on flashing the Seeed Xiao.

## Customizing the Firmware

If you wish to modify the firmware to suit your needs, follow these steps:

1. Install firmware for flashing from the Arduino IDE (not needed if flashing UF2).
2. For RP2040 flashing, refer to the [Waveshare Wiki](https://www.waveshare.com/wiki/RP2040-Touch-LCD-1.28) for detailed instructions.

Feel free to customize and experiment with the firmware to create your own unique smartwatch experience!

# RP2040 Smartwatch

The RP2040 Smartwatch is a customizable wearable device powered by the Raspberry Pi RP2040 microcontroller. This README provides information on how to flash the firmware and wire the required components.

## Flashing Instructions

To flash the firmware onto the RP2040 Smartwatch, follow these steps:

1. Hold down the **Reset** button.
2. While holding down **Reset**, also hold down the **Boot** button.
3. Release the **Reset** button.

This will put the device into firmware flash mode, allowing you to upload the desired firmware.

### Firmware Files

- **UF2 File (RP2040):** UF2 file for the RP2040 microcontroller can be found in the [Releases section](https://github.com/KaiyoFox/waveshare1.28-rp2040-smartwatch/releases/latest). This file is used for flashing the RP2040.
- **Seeed.ino File (Seeed Xiao):** This file is used for flashing the Seeed Xiao and can be found in the repository.

## Required Components

### RP2040 Touch LCD 1.28" Display

The RP2040 Smartwatch utilizes the Waveshare RP2040 Touch LCD 1.28" round display. You can find more information and purchase the display from [Waveshare](https://www.waveshare.com/rp2040-touch-lcd-1.28.htm).

### Seeed Xiao BLE nRF52840

The Seeed Xiao BLE nRF52840 is used for its Bluetooth capabilities. You can find more information and purchase the Seeed Xiao BLE from [Seeed Studio](https://www.seeedstudio.com/Seeed-XIAO-BLE-nRF52840-p-5201.html).

## Wiring Diagram

| RP2040 Pin | Seeed Pin / Other |
|------------|-----------|
| GND | GND |
| VSYS | 3V3 |
| Run | D1 |
| Boot | D0 |
| GND2 | Connect to GPIO 26 on RP2040 via a 100k resistor and button |
| ADC_AVDD | Other end of button |
| GPIO 16 | D5 |
| GPIO 17 | D4 |
| GPIO 18 | D3 |
| GPIO 26 | Connect to 100k resistor that is on GND2 |
| GPIO 27 | Unused |
| GPIO 28 | Haptic Motor + |

Note: On the button put a capacitor on both ends, Negative on GND2

## Flashing the Seeed Xiao

Please refer to the [Seeed Studio Wiki](https://wiki.seeedstudio.com/XIAO_BLE/) for instructions on flashing the Seeed Xiao.

## Customizing the Firmware

If you wish to modify the firmware to suit your needs, follow these steps:

1. Install firmware for flashing from the Arduino IDE (not needed if flashing UF2).
2. For RP2040 flashing, refer to the [Waveshare Wiki](https://www.waveshare.com/wiki/RP2040-Touch-LCD-1.28) for detailed instructions.

Feel free to customize and experiment with the firmware to create your own unique smartwatch experience!

12 changes: 12 additions & 0 deletions RP2040-Touch-LCD-1.28/App.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef APP_H
#define APP_H

class App {
public:
virtual void sysConfig() = 0; // Pure virtual function
virtual void launch() = 0; // Pure virtual function
virtual void update() = 0; // Pure virtual function
virtual ~App() {} // Virtual destructor
};

#endif
170 changes: 75 additions & 95 deletions RP2040-Touch-LCD-1.28/CST816S.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,120 +14,100 @@
#include "CST816S.h"
CST816S Touch_CTS816;

void CST816S_I2C_Write(uint8_t reg, uint8_t value)
{
DEV_I2C_Write_Byte( CST816_ADDR, reg, value);
void CST816S_I2C_Write(uint8_t reg, uint8_t value) {
DEV_I2C_Write_Byte(CST816_ADDR, reg, value);
}
uint8_t CST816S_I2C_Read(uint8_t reg)
{
uint8_t res;
res = DEV_I2C_Read_Byte(CST816_ADDR, reg);
return res;
uint8_t CST816S_I2C_Read(uint8_t reg) {
uint8_t res;
res = DEV_I2C_Read_Byte(CST816_ADDR, reg);
return res;
}

uint8_t CST816S_WhoAmI()
{
if (CST816S_I2C_Read(CST816_ChipID) == 0xB5)
return true;
else
return false;
uint8_t CST816S_WhoAmI() {
if (CST816S_I2C_Read(CST816_ChipID) == 0xB5)
return true;
else
return false;
}

void CST816S_Reset()
{
DEV_Digital_Write(Touch_RST_PIN, 0);
DEV_Delay_ms(100);
DEV_Digital_Write(Touch_RST_PIN, 1);
DEV_Delay_ms(100);
void CST816S_Reset() {
DEV_Digital_Write(Touch_RST_PIN, 0);
DEV_Delay_ms(100);
DEV_Digital_Write(Touch_RST_PIN, 1);
DEV_Delay_ms(100);
}

uint8_t CST816S_Read_Revision()
{
return CST816S_I2C_Read(CST816_FwVersion);
uint8_t CST816S_Read_Revision() {
return CST816S_I2C_Read(CST816_FwVersion);
}

void CST816S_Wake_up()
{
DEV_Digital_Write(Touch_RST_PIN, 0);
DEV_Delay_ms(10);
DEV_Digital_Write(Touch_RST_PIN, 1);
DEV_Delay_ms(50);
CST816S_I2C_Write(CST816_DisAutoSleep, 0x01);
void CST816S_Wake_up() {
DEV_Digital_Write(Touch_RST_PIN, 0);
DEV_Delay_ms(10);
DEV_Digital_Write(Touch_RST_PIN, 1);
DEV_Delay_ms(50);
CST816S_I2C_Write(CST816_DisAutoSleep, 0x01);
}

void CST816S_Stop_Sleep()
{
CST816S_I2C_Write(CST816_DisAutoSleep, 0x01);
void CST816S_Stop_Sleep() {
CST816S_I2C_Write(CST816_DisAutoSleep, 0x01);
}

void CST816S_Set_Mode(uint8_t mode)
{
if (mode == CST816S_Point_Mode)
{
//
CST816S_I2C_Write(CST816_IrqCtl, 0x41);

}
else if (mode == CST816S_Gesture_Mode)
{
CST816S_I2C_Write(CST816_IrqCtl, 0X11);
CST816S_I2C_Write(CST816_MotionMask, 0x01);
}
else
{
CST816S_I2C_Write(CST816_IrqCtl, 0X71);
}

void CST816S_Set_Mode(uint8_t mode) {
if (mode == CST816S_Point_Mode) {
//
CST816S_I2C_Write(CST816_IrqCtl, 0x41);

} else if (mode == CST816S_Gesture_Mode) {
CST816S_I2C_Write(CST816_IrqCtl, 0X11);
CST816S_I2C_Write(CST816_MotionMask, 0x01);
} else {
CST816S_I2C_Write(CST816_IrqCtl, 0X71);
}
}



uint8_t CST816S_init(uint8_t mode)
{
uint8_t bRet, Rev;
CST816S_Reset();

bRet = CST816S_WhoAmI();
if (bRet)
{
printf("Success:Detected CST816T.\r\n");
Rev = CST816S_Read_Revision();
printf("CST816T Revision = %d\r\n", Rev);
CST816S_Stop_Sleep();
}
else
{
printf("Error: Not Detected CST816T.\r\n");
return false;
}

CST816S_Set_Mode(mode);
Touch_CTS816.x_point = 0;
Touch_CTS816.y_point = 0;
CST816S_I2C_Write(CST816_IrqPluseWidth, 0x01);
CST816S_I2C_Write(CST816_NorScanPer, 0x01);

Touch_CTS816.mode = mode;
uint8_t CST816S_init(uint8_t mode) {
uint8_t bRet, Rev;
CST816S_Reset();

return true;
bRet = CST816S_WhoAmI();
if (bRet) {
printf("Success:Detected CST816T.\r\n");
Rev = CST816S_Read_Revision();
printf("CST816T Revision = %d\r\n", Rev);
CST816S_Stop_Sleep();
} else {
printf("Error: Not Detected CST816T.\r\n");
return false;
}

CST816S_Set_Mode(mode);
Touch_CTS816.x_point = 0;
Touch_CTS816.y_point = 0;
CST816S_I2C_Write(CST816_IrqPluseWidth, 0x01);
CST816S_I2C_Write(CST816_NorScanPer, 0x01);

Touch_CTS816.mode = mode;

return true;
}

CST816S CST816S_Get_Point()
{
uint8_t x_point_h, x_point_l, y_point_h, y_point_l;
// CST816S_Wake_up();
x_point_h = CST816S_I2C_Read(CST816_XposH);
x_point_l = CST816S_I2C_Read(CST816_XposL);
y_point_h = CST816S_I2C_Read(CST816_YposH);
y_point_l = CST816S_I2C_Read(CST816_YposL);
Touch_CTS816.x_point = ((x_point_h & 0x0f) << 8) + x_point_l;
Touch_CTS816.y_point = ((y_point_h & 0x0f) << 8) + y_point_l;

return Touch_CTS816;
CST816S CST816S_Get_Point() {
uint8_t x_point_h, x_point_l, y_point_h, y_point_l;
// CST816S_Wake_up();
x_point_h = CST816S_I2C_Read(CST816_XposH);
x_point_l = CST816S_I2C_Read(CST816_XposL);
y_point_h = CST816S_I2C_Read(CST816_YposH);
y_point_l = CST816S_I2C_Read(CST816_YposL);
Touch_CTS816.x_point = ((x_point_h & 0x0f) << 8) + x_point_l;
Touch_CTS816.y_point = ((y_point_h & 0x0f) << 8) + y_point_l;

return Touch_CTS816;
}
uint8_t CST816S_Get_Gesture(void)
{
uint8_t gesture;
gesture=CST816S_I2C_Read(CST816_GestureID);
return gesture;
uint8_t CST816S_Get_Gesture(void) {
uint8_t gesture;
gesture = CST816S_I2C_Read(CST816_GestureID);
return gesture;
}
Loading

0 comments on commit d2a4063

Please sign in to comment.