1
+ #include "../gemini_app_i.h"
2
+
3
+ #define TEXT_BUFFER_SIZE 128
4
+ static char text_buffer [TEXT_BUFFER_SIZE ];
5
+
6
+ enum {
7
+ GeminiSceneStartChattingEventOk ,
8
+ } GeminiSceneStartChattingEvent ;
9
+
10
+ static void gemini_scene_start_chatting_text_input_callback (void * context ) {
11
+ GeminiApp * app = context ;
12
+ scene_manager_handle_custom_event (app -> scene_manager , GeminiSceneStartChattingEventOk );
13
+ }
14
+
15
+ void gemini_scene_start_chatting_on_enter (void * context ) {
16
+ GeminiApp * app = context ;
17
+ text_input_set_header_text (app -> text_input , "Enter message" );
18
+ text_input_set_minimum_length (app -> text_input , 0 );
19
+ text_buffer [0 ] = '\0' ;
20
+ text_input_set_result_callback (app -> text_input , gemini_scene_start_chatting_text_input_callback , app , text_buffer , TEXT_BUFFER_SIZE , true);
21
+ view_dispatcher_switch_to_view (app -> view_dispatcher , GeminiViewTextInput );
22
+ }
23
+
24
+ bool gemini_scene_start_chatting_on_event (void * context , SceneManagerEvent event ) {
25
+ GeminiApp * app = context ;
26
+ bool consumed = false;
27
+ if (event .type == SceneManagerEventTypeCustom ) {
28
+ switch (event .event ) {
29
+ case GeminiSceneStartChattingEventOk :
30
+ if (strlen (text_buffer ) > 0 ) {
31
+ uart_helper_send (app -> uart_helper , text_buffer , 0 );
32
+ // We want BACK to go back to the start chatting scene.
33
+ gemini_scene_receive_serial_set_next (app , GeminiSceneStartChatting );
34
+ scene_manager_search_and_switch_to_another_scene (app -> scene_manager , GeminiSceneReceiveSerial );
35
+ consumed = true;
36
+ } else {
37
+ scene_manager_previous_scene (app -> scene_manager );
38
+ consumed = true;
39
+ }
40
+ break ;
41
+ }
42
+ }
43
+
44
+ return consumed ;
45
+ }
46
+
47
+ void gemini_scene_start_chatting_on_exit (void * context ) {
48
+ UNUSED (context );
49
+ }
0 commit comments