diff options
| Commit | 63fbf3df12dce61caf168637841f7ff938da7a94 (patch) | |
|---|---|---|
| Author | 2024-05-05 17:05:58 +0300 | |
| Committer | 2024-05-05 17:05:58 +0300 | |
| Files | 27fa75808072222578cb7917f0d9a45ce23b4c71 | |
| uni-projects-63fbf3df12dce61caf168637841f7ff938da7a94.tar uni-projects-63fbf3df12dce61caf168637841f7ff938da7a94.tar.gz uni-projects-63fbf3df12dce61caf168637841f7ff938da7a94.zip | ||
| Parent | b44b78b596f0d2e15eb29b1a89d6cf431959a322 (diff) | |
[iot/goam] Implemented write_data and changing image resolution
3 files changed, 77 insertions, 4 deletions
| -rw-r--r-- | Year 3/Internet of things/goam/main/main.c | 1 | ||||
| -rw-r--r-- | Year 3/Internet of things/goam/main/ptc06.c | 73 | ||||
| -rw-r--r-- | Year 3/Internet of things/goam/main/ptc06.h | 7 |
diff --git a/Year 3/Internet of things/goam/main/main.c b/Year 3/Internet of things/goam/main/main.c index 0903ff5..b1e9b99 100644 --- a/Year 3/Internet of things/goam/main/main.c +++ b/Year 3/Internet of things/goam/main/main.c @@ -75,6 +75,7 @@ void app_main(void) ptc06_init(); + ptc06_set_image_resolution(RES_160X120); char* image; size_t length = ptc06_get_image(&image); for (int i = 0; i < length; i++) { diff --git a/Year 3/Internet of things/goam/main/ptc06.c b/Year 3/Internet of things/goam/main/ptc06.c index 60a12fc..34385ef 100644 --- a/Year 3/Internet of things/goam/main/ptc06.c +++ b/Year 3/Internet of things/goam/main/ptc06.c @@ -102,11 +102,44 @@ static void init_camera() { */ enum Command { - GEN_VERSION = 0x11, - SYSTEM_RESET = 0x26, - READ_FBUF = 0x32, + GEN_VERSION = 0x11, // Not implemented + SET_SERIAL_NUMBER = 0x21, // Not implemented + SET_PORT = 0x24, // Not implemented + SYSTEM_RESET = 0x26, + + READ_DATA = 0x30, // Not implemented + WRITE_DATA = 0x31, + READ_FBUF = 0x32, + WRITE_FBUF = 0x33, // Not implemented GET_FBUF_LEN = 0x34, - FBUF_CTRL = 0x36 + SET_FBUF_LEN = 0x35, // Not implemented + FBUF_CTRL = 0x36, + + COMM_MOTION_CTRL = 0x37, // Not implemented + COMM_MOTION_STATUS = 0x38, // Not implemented + COMM_MOTION_DETECTED = 0x39, // Not implemented + MIRROR_CTRL = 0x3A, // Not implemented + MIRROR_STATUS = 0x3B, // Not implemented + COLOR_CTRL = 0x3C, // Not implemented + COLOR_STATUS = 0x3D, // Not implemented + POWER_SAVE_CTRL = 0x3E, // Not implemented + POWER_SAVE_STATUS = 0x3F, // Not implemented + + AE_CTRL = 0x40, // Not implemented + AE_STATUS = 0x41, // Not implemented + MOTION_CTRL = 0x42, // Not implemented + MOTION_STATUS = 0x43, // Not implemented + TV_OUT_CTRL = 0x44, // Not implemented + OSD_ADD_CHAR = 0x45, // Not implemented + DOWNSIZE_CTRL = 0x54, // Not implemented + DOWNSIZE_STATUS = 0x55, // Not implemented + + GET_FLASH_SIZE = 0x60, // Not implemented + ERASE_FLASH_SECTOR = 0x61, // Not implemented + ERASE_FLASH_ALL = 0x62, // Not implemented + READ_LOGO = 0x70, // Not implemented + SET_BITMAP = 0x71, // Not implemented + BATCH_WRITE = 0x80 // Not implemented }; static void send(enum Command comm_byte, const char data_lengths, char data[16]) { @@ -214,6 +247,32 @@ static size_t vc0706_read_fbuf(enum FBufType fbt_byte, enum ControlMode cm_byte, return length; } +enum DeviceType { + CHIP_REGISTER = 0x01, + SENSOR_REGISTER = 0x02, + CCIR656_REGISTER = 0x03, + I2C_EEPROM = 0x04, + SPI_EEPROM = 0x05, + SPI_FLASH = 0x06 +}; + +static char temp_configuration[4]; +static char temp_write_data[14]; + +static void vc0706_write_data(enum DeviceType dt_byte, char write_data_len, const char configuration[4], const char write_data[14]) { + size_t configuration_size = 2; + if (dt_byte == SENSOR_REGISTER || dt_byte == CCIR656_REGISTER) configuration_size = 3; + if (dt_byte == SPI_FLASH) configuration_size = 4; + + temp_data[0] = dt_byte; + temp_data[1] = write_data_len; + append(temp_data + 2, configuration, configuration_size); + append(temp_data + 2 + configuration_size, write_data, write_data_len); + + send(WRITE_DATA, 2 + configuration_size + write_data_len, temp_data); + recv(WRITE_DATA, 0, temp_ack); +} + /* * Public interface */ @@ -246,6 +305,12 @@ size_t ptc06_get_image(char** image) { return length; } +void ptc06_set_image_resolution(enum Resolution res) { + temp_configuration[0] = 0x00; + temp_configuration[1] = 0x19; + temp_write_data[0] = res; + vc0706_write_data(I2C_EEPROM, 0x01, temp_configuration, temp_write_data); +} diff --git a/Year 3/Internet of things/goam/main/ptc06.h b/Year 3/Internet of things/goam/main/ptc06.h index 17816a9..a4f1d48 100644 --- a/Year 3/Internet of things/goam/main/ptc06.h +++ b/Year 3/Internet of things/goam/main/ptc06.h @@ -3,3 +3,10 @@ void ptc06_init(); void ptc06_reset(); size_t ptc06_get_image(char** image); + +enum Resolution { + RES_640X480 = 0x00, + RES_320X240 = 0x11, + RES_160X120 = 0x22 +}; +void ptc06_set_image_resolution(enum Resolution res); |
