Skip to content

Technical documentation

Albin Söderqvist edited this page Aug 23, 2020 · 13 revisions

Current consumption

Sleep Screen on
1.07mA between 12 and 15mA

Hardware and drivers

CST816S touch controller

Datasheet

Someone from the PineTime community e-mailed thynitron.com.cn asking for information about the CST816S for FOSS development and received some documents. The tables below were made after reading those.

Register description

Name Address description
CST816S_REG_DATA 0x00
CST816S_REG_GESTURE_ID 0x01 See (CST816S_GESTURE_XXX definitions)[#gesture-description]. 8-bit value.
CST816S_REG_FINGER_NUM 0x02 Number of fingers. 8-bit value.
CST816S_REG_XPOS_H 0x03 X coordinate 4 digits high X (Bit 3-0 : Xpos[11:8])
CST816S_REG_XPOS_L 0x04 X coordinate 8 bits lower (Xpos[7:0])
CST816S_REG_YPOS_H 0x05 Y coordinate 4 digits high Y (Bit 3-0 : Ypos[11:8])
CST816S_REG_YPOS_L 0x06 Y coordinate 8 bits lower (Ypos[7:0])
... ... ...
 CST816S_REG_BPC1L 0xB0 High 8 bits of BPC0 value
 CST816S_REG_BPC0L 0xB1 Lower 8 bits of BPC0 value
 CST816S_REG_BPC1H 0xB2 High 8 bits of BPC1 value
 CST816S_REG_BPC1L 0xB3 Lower 8 bits of BPC1 value.
 CST816S_REG_CHIP_ID 0xA7 Chip model
CST816S_REG_PROJ_ID 0xA8 Project number
CST816S_REG_FW_VERSION 0xA9 Firmware Version. 8-bit value.
CST816S_REG_MOTION_MASK 0xEC See CST816S_MOTION_EN_XXX definitions.
CST816S_REG_IRQ_PULSE_WIDTH 0xED Interrupt low pulse output width. Unit: 0.1ms, Optional value: 1~200. Default value: 10. 8-bit value.
CST816S_REG_NOR_SCAN_PER 0xEE Normal fast detection cycle. This value affects LpAutoWakeTime and AutoSleepTime. in units of 10ms. Selectable value: 1~30. default value is 1. 8-bit value.
CST816S_REG_MOTION_S1_ANGLE 0xEF Gesture detection sliding partition angle control. angle=tan(c)*10 c is the angle based on the positive direction of the x-axis. 8-bit value
CST816S_REG_LP_SCAN_RAW1H 0xF0 Low power consumption scans the high 8 bits of the reference value of channel 1.
CST816S_REG_LP_SCAN_RAW1L 0xF1 Low power consumption scans the lower 8 bits of the reference value of channel 1.
CST816S_REG_LP_SCAN_RAW2H 0xF2 Low power consumption scans the high 8 bits of the reference value of channel 1. (Seems like bad copy paste in the chinese datasheet, chanel 2 ? I don't understand what is this...)
CST816S_REG_LP_SCAN_RAW2L 0xF3 Low power consumption scan 8 bits lower than the reference value of channel 1. (Seems like bad copy paste in the chinese datasheet, chanel 2 ? I don't understand what is this...)
CST816S_REG_LP_AUTO_WAKEUP_TIME 0xF4 Auto recalibration period when the power consumption is low. Unit: 1 minute, selectable value: 1~5. default value is 5. 8-bit value.
CST816S_REG_LP_SCAN_TH 0xF5 Low-power scan wake-up threshold. The smaller the smaller the more sensitive. Selectable value: 1~255. Default value is 48.
CST816S_REG_LP_SCAN_WIN 0xF6 Low-power scanning range. The larger the range, the more sensitive it is and the higher the power consumption. Selectable values: 0, 1, 2, 3. Default value is 3. 8-bit value.
CST816S_REG_LP_SCAN_FREQ 0xF7 Low power consumption scanning frequency. Smaller is more sensitive. Selectable value: 1~255. Default value is 7.
CST816S_REG_LP_SCAN_I_DAC 0xF8 Low-power scanning current. The smaller the current, the more sensitive it is. Selectable value: 1~255. 8-bit value.
CST816S_REG_AUTOSLEEP_TIME 0xF9 When there is no touch within x seconds, it automatically enters the low-power mode. The unit is in sec and the default value is 2. 8-bit value.
CST816S_REG_IRQ_CTL 0xFA See CST816S_IRQ_XXX definitions
CST816S_REG_DEBOUNCE_TIME 0xFB When there is a touch but no valid gesture within x seconds, the function is automatically reset. The unit is sec. This function is not enabled when it is 0. The default is 5s. 8-bit value.
CST816S_REG_LONG_PRESS_TIME 0xFC Press and hold x seconds to reset automatically. The unit is sec. This function is not enabled when it is 0. The default is 10s. 8-bit value.
CST816S_REG_IOCTL 0xFD See CST816S_IOCTL_XXX definitions
CST816S_REG_DIS_AUTO_SLEEP 0xFE Default 0 = enable auto sleep. Any other means disable the feature. 8-bit value.

Gesture description

Gesture Value Description
CST816S_GESTURE_NONE (0x00) No hand gesture detected.
CST816S_GESTURE_SLIDE_UP (0x01) Slide up gesture detected.
CST816S_GESTURE_SLIDE_DOWN (0x02) Slide down gesture detected.
CST816S_GESTURE_SLIDE_LEFT (0x03) Slide left gesture detected.
CST816S_GESTURE_SLIDE_RIGHT (0x04) Slide right gesture detected.
CST816S_GESTURE_CLICK (0x05) Click (touch and release) gesture detected.
CST816S_GESTURE_DOUBLE_CLICK (0x0B) Double click gesture detected.
CST816S_GESTURE_LONG_PRESS (0x0C) Long press gesture detected.

Motion Enable Register

Continuous sliding here means that interrupt will be triggered not once the slide motion is over but all along the sliding. So for a single sliding gesture several interrupts will be generated.

This option could be used for precise scrolling operations for example (just an idea).

Motion Value Description
CST816S_MOTION_EN_CON_LR (1<<2) Continuous left/right sliding action is possible
CST816S_MOTION_EN_CON_UR (1<<1) Enables a continuous up and down sliding motion
CST816S_MOTION_EN_DCLICK (1<<0) Enables double-click action

Interrupt Enable Register

Touch and motions are mutually exclusive. En Touch is enable, Motion will be disabled in this register.

IRQ Value Description
CST816S_IRQ_EN_TEST (1<<7) Interrupt pin test, enable and then automatically periodically emit low pulses.
CST816S_IRQ_EN_TOUCH (1<<6) Enables touch event. When a touch is detected, a low pulse is emitted periodically.
CST816S_IRQ_EN_CHANGE (1<<5) A low pulse is emitted when a change in touch condition is detected.
CST816S_IRQ_EN_MOTION (1<<4) When a gesture is detected, a low pulse is emitted.
CST816S_IRQ_ONCE_WLP (1<<0) Press and hold gesture and only one low pulse signal is emitted.

IO Control Register

IOCTL Value Description
CST816S_IOCTL_SOFT_RTS (1<<2) The main control can achieve the soft reset function of touch by pulling down the IRQ pin. 0: Disables soft reset. 1: Enables soft reset.
CST816S_IOCTL_IIC_OD (1<<1) IIC pin drive mode. Default is resistor pull-up. 0: resistive pull-up 1:OD
CST816S_IOCTL_EN_1V8 (1<<0) IIC and IRQ pin level selection. Default is VDD level. 0:VDD 1:1.8V