Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
toerb
flow3r firmware
Commits
22fc7de5
Commit
22fc7de5
authored
2 years ago
by
moon2
Browse files
Options
Downloads
Patches
Plain Diff
integrated new captouch driver
parent
600eae34
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
components/badge23/captouch.c
+57
-44
57 additions, 44 deletions
components/badge23/captouch.c
components/badge23/espan.c
+3
-7
3 additions, 7 deletions
components/badge23/espan.c
components/badge23/include/badge23/captouch.h
+1
-0
1 addition, 0 deletions
components/badge23/include/badge23/captouch.h
with
61 additions
and
51 deletions
components/badge23/captouch.c
+
57
−
44
View file @
22fc7de5
...
@@ -34,7 +34,6 @@ static const char *TAG = "captouch";
...
@@ -34,7 +34,6 @@ static const char *TAG = "captouch";
static
const
struct
ad714x_chip
*
chip_top
;
static
const
struct
ad714x_chip
*
chip_top
;
static
const
struct
ad714x_chip
*
chip_bot
;
static
const
struct
ad714x_chip
*
chip_bot
;
void
captouch_force_calibration
(){}
struct
ad714x_chip
{
struct
ad714x_chip
{
uint8_t
addr
;
uint8_t
addr
;
...
@@ -55,7 +54,7 @@ static const struct ad714x_chip chip_bot_rev5 = {.addr = AD7147_BASE_ADDR , .
...
@@ -55,7 +54,7 @@ static const struct ad714x_chip chip_bot_rev5 = {.addr = AD7147_BASE_ADDR , .
static const struct ad714x_chip chip_top = {.addr = AD7147_BASE_ADDR + 1, .gpio = 48, .afe_offsets = {24, 12, 16, 33, 30, 28, 31, 27, 22, 24, 18, 19, }, .stages=top_stages};
static const struct ad714x_chip chip_top = {.addr = AD7147_BASE_ADDR + 1, .gpio = 48, .afe_offsets = {24, 12, 16, 33, 30, 28, 31, 27, 22, 24, 18, 19, }, .stages=top_stages};
static const struct ad714x_chip chip_bot = {.addr = AD7147_BASE_ADDR, .gpio = 3, .afe_offsets = {3, 2, 1, 1 ,1, 1, 1, 1, 2, 3}, .stages=bottom_stages};
static const struct ad714x_chip chip_bot = {.addr = AD7147_BASE_ADDR, .gpio = 3, .afe_offsets = {3, 2, 1, 1 ,1, 1, 1, 1, 2, 3}, .stages=bottom_stages};
*/
*/
static
void
captouch_task
(
void
*
arg
);
//
static void captouch_task(void* arg);
static
esp_err_t
ad714x_i2c_write
(
const
struct
ad714x_chip
*
chip
,
const
uint16_t
reg
,
const
uint16_t
data
)
static
esp_err_t
ad714x_i2c_write
(
const
struct
ad714x_chip
*
chip
,
const
uint16_t
reg
,
const
uint16_t
data
)
{
{
...
@@ -320,7 +319,7 @@ void captouch_init(void)
...
@@ -320,7 +319,7 @@ void captouch_init(void)
TaskHandle_t
handle
;
TaskHandle_t
handle
;
//xTaskCreatePinnedToCore(&captouch_task, "captouch", 4096, NULL, configMAX_PRIORITIES - 2, &handle, 1);
//xTaskCreatePinnedToCore(&captouch_task, "captouch", 4096, NULL, configMAX_PRIORITIES - 2, &handle, 1);
xTaskCreate
(
&
captouch_task
,
"captouch"
,
4096
,
NULL
,
configMAX_PRIORITIES
-
2
,
&
handle
);
//
xTaskCreate(&captouch_task, "captouch", 4096, NULL, configMAX_PRIORITIES - 2, &handle);
}
}
static
void
print_cdc
(
uint16_t
*
data
)
static
void
print_cdc
(
uint16_t
*
data
)
...
@@ -351,13 +350,21 @@ uint16_t cdc_ambient[2][12] = {0,};
...
@@ -351,13 +350,21 @@ uint16_t cdc_ambient[2][12] = {0,};
//extern void espan_handle_captouch(uint16_t pressed_top, uint16_t pressed_bot);
//extern void espan_handle_captouch(uint16_t pressed_top, uint16_t pressed_bot);
static
void
captouch_task
(
void
*
arg
)
static
uint8_t
calib_cycles
=
0
;
{
void
captouch_force_calibration
()
{
i
nt
cycle
=
0
;
i
f
(
!
calib_cycles
){
//last calib has finished
calib_cycles
=
16
;
//goal cycles, can be argument someday
}
// TODO: keep constant track of ambient or allow recalibration
}
void
captouch_read_cycle
(){
static
int
cycle
=
0
;
static
uint8_t
calib_cycle
=
0
;
vTaskDelay
(
10
/
portTICK_PERIOD_MS
);
if
(
calib_cycles
){
if
(
calib_cycle
==
0
){
// last cycle has finished
calib_cycle
=
calib_cycles
;
}
uint32_t
ambient_acc
[
2
][
12
]
=
{{
0
,},
{
0
,}};
uint32_t
ambient_acc
[
2
][
12
]
=
{{
0
,},
{
0
,}};
for
(
int
i
=
0
;
i
<
16
;
i
++
)
{
for
(
int
i
=
0
;
i
<
16
;
i
++
)
{
vTaskDelay
(
10
/
portTICK_PERIOD_MS
);
vTaskDelay
(
10
/
portTICK_PERIOD_MS
);
...
@@ -372,14 +379,15 @@ static void captouch_task(void* arg)
...
@@ -372,14 +379,15 @@ static void captouch_task(void* arg)
}
}
// TODO: use median instead of average
// TODO: use median instead of average
calib_cycle
--
;
if
(
!
calib_cycle
){
//calib cycle is complete
for
(
int
i
=
0
;
i
<
12
;
i
++
){
for
(
int
i
=
0
;
i
<
12
;
i
++
){
cdc_ambient
[
0
][
i
]
=
ambient_acc
[
0
][
i
]
/
16
;
cdc_ambient
[
0
][
i
]
=
ambient_acc
[
0
][
i
]
/
calib_cycles
;
cdc_ambient
[
1
][
i
]
=
ambient_acc
[
1
][
i
]
/
16
;
cdc_ambient
[
1
][
i
]
=
ambient_acc
[
1
][
i
]
/
calib_cycles
;
}
}
calib_cycles
=
0
;
}
while
(
true
)
{
}
else
{
vTaskDelay
(
10
/
portTICK_PERIOD_MS
);
cycle
++
;
cycle
++
;
ad714x_i2c_read
(
chip_top
,
0xB
,
cdc_data
[
0
],
chip_top
->
stages
);
ad714x_i2c_read
(
chip_top
,
0xB
,
cdc_data
[
0
],
chip_top
->
stages
);
...
@@ -396,7 +404,12 @@ static void captouch_task(void* arg)
...
@@ -396,7 +404,12 @@ static void captouch_task(void* arg)
print_ambient
(
cdc_ambient
[
1
]);
print_ambient
(
cdc_ambient
[
1
]);
print_cdc
(
cdc_data
[
1
]);
print_cdc
(
cdc_data
[
1
]);
}
}
//espan_handle_captouch(pressed_top, pressed_bot);
}
}
static
void
captouch_task
(
void
*
arg
)
{
while
(
true
)
{
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
components/badge23/espan.c
+
3
−
7
View file @
22fc7de5
...
@@ -63,17 +63,13 @@ void os_app_main(void)
...
@@ -63,17 +63,13 @@ void os_app_main(void)
captouch_init
();
captouch_init
();
vTaskDelay
(
2000
/
portTICK_PERIOD_MS
);
vTaskDelay
(
2000
/
portTICK_PERIOD_MS
);
set_global_vol_dB
(
0
);
//
set_global_vol_dB(0);
captouch_force_calibration
();
display_init
();
display_init
();
while
(
1
)
{
while
(
1
)
{
manual_captouch_readout
(
1
);
vTaskDelay
((
CAPTOUCH_POLLING_PERIOD
)
/
portTICK_PERIOD_MS
);
manual_captouch_readout
(
0
);
vTaskDelay
((
CAPTOUCH_POLLING_PERIOD
)
/
portTICK_PERIOD_MS
);
vTaskDelay
((
CAPTOUCH_POLLING_PERIOD
)
/
portTICK_PERIOD_MS
);
update_button_state
();
update_button_state
();
vTaskDelay
((
CAPTOUCH_POLLING_PERIOD
)
/
portTICK_PERIOD_MS
);
captouch_read_cycle
();
//display_draw_scope();
}
}
ESP_ERROR_CHECK
(
i2c_driver_delete
(
I2C_MASTER_NUM
));
ESP_ERROR_CHECK
(
i2c_driver_delete
(
I2C_MASTER_NUM
));
...
...
This diff is collapsed.
Click to expand it.
components/badge23/include/badge23/captouch.h
+
1
−
0
View file @
22fc7de5
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
#include
<stdint.h>
#include
<stdint.h>
void
captouch_init
(
void
);
void
captouch_init
(
void
);
void
captouch_read_cycle
(
void
);
void
captouch_print_debug_info
(
void
);
void
captouch_print_debug_info
(
void
);
void
gpio_event_handler
(
void
*
arg
);
void
gpio_event_handler
(
void
*
arg
);
void
manual_captouch_readout
(
uint8_t
top
);
void
manual_captouch_readout
(
uint8_t
top
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment