Skip to content

Commit

Permalink
Merge branch 'firmware_v0p3' of github.com:CaydenPierce/OpenSourceSma…
Browse files Browse the repository at this point in the history
…rtGlasses into firmware_v0p3
  • Loading branch information
CaydenPierce committed Jan 4, 2023
2 parents 48d4576 + 02223a1 commit ece51e5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ void displayStart(){
//Wipe everything from screen
void displayClear(){
lvgl_acquire();
lv_obj_t * currentScreen = lv_scr_act();
lv_scr_load(blankScreen);
lcd.setBrightness(0);
lvgl_release();
}

void screenTimerCallback(void* arg){
ESP_LOGI(TAG, "SCREEN TIMER CALLBACK TRIGGERED");
displayClear();
power_to_display(false);
}
Expand All @@ -108,11 +108,12 @@ void updateClock(){
// Call this when turning on or updating the screen
// (updates the screen shutoff timer)
void updateActivity(int timeoutSeconds = 5){
ESP_LOGI(TAG, "UPDATE ACTIVITY TRIGGERED");
power_to_display(true); //TODO: evaluate putting this here
lcd.setBrightness(128);

uint64_t timeoutMicroSeconds = timeoutSeconds * 1000000;
esp_timer_stop(screenTimer); //make sure it's not running anymore
if(timeoutSeconds == -1) timeoutMicroSeconds = INT64_MAX;
esp_timer_start_once(screenTimer, timeoutMicroSeconds);
}

Expand Down Expand Up @@ -140,26 +141,33 @@ void displayEnterVoiceCommandStep3(char* command, char* soFar){
lvgl_release();
}

char * currentCaption = "";
void displayLiveCaptions(char* body = ""){

currentCaption = strcat(currentCaption, body);
string currCapStr(currentCaption);
if(currCapStr.length() > MAX_CAPTION_LENGTH) currCapStr = currCapStr.substr(currCapStr.length()/2);
currentCaption = &currCapStr[0];

updateActivity(INT_MAX);
string previousTitle = "";
string currentCaptionString = "";
void displayLiveCaptions(char* title = "", char* body = ""){
ESP_LOGI(TAG, "DISP LIVE CAPTIONS CALLED WITH TITLE: %s, BODY: %s", title, body);
string titleString(title);
string bodyString(body);
if(titleString != previousTitle) currentCaptionString = "";
if(currentCaptionString.length() > 0) currentCaptionString += "\n\n";
previousTitle = titleString;
currentCaptionString = currentCaptionString + bodyString;
//ESP_LOGI(TAG, "NEW CAPTION: " + currentCaptionString);
if(currentCaptionString.length() > MAX_CAPTION_LENGTH) currentCaptionString = currentCaptionString.substr(currentCaptionString.length()/2);

updateActivity(-1);
lvgl_acquire();
if(lv_scr_act() == ui_Card_Live_Captions) //TODO: investigate why this only works sporatically
{
ESP_LOGI(TAG, "UPDATE LIVE CAPTION SCREEN");
lv_label_set_text(ui_Card_Live_Captions_Content, currentCaption);
lv_label_set_text(ui_Card_Live_Captions_Title, title);
lv_label_set_text(ui_Card_Live_Captions_Content, &currentCaptionString[0]);
lv_obj_scroll_to_y(ui_Card_Live_Captions_Content, SHRT_MAX, LV_ANIM_ON);
}
else
{
ESP_LOGI(TAG, "NEW LIVE CAPTION SCREEN");
lv_label_set_text(ui_Card_Live_Captions_Content, currentCaption);
lv_label_set_text(ui_Card_Live_Captions_Title, title);
lv_label_set_text(ui_Card_Live_Captions_Content, &currentCaptionString[0]);
lv_scr_load(ui_Card_Live_Captions);
lv_obj_scroll_to_y(ui_Card_Live_Captions_Content, SHRT_MAX, LV_ANIM_OFF);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extern void displayEnterVoiceCommandStep2();
extern void displayEnterVoiceCommandStep3(char* command, char* soFar);
//extern void displayEnterVoiceCommandStep3(string command, string soFar);
extern void displaySearchEngineResult(char* title, char* body, char* image = "");
extern void displayLiveCaptions(char* body = "");
extern void displayLiveCaptions(char* title = "", char* body = "");
extern void updateClock();
// extern MessageTypes messageTypesList;
// extern char* currentMode;
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void eventDistributor(void *args){
char * body = (*jsonMessageParser).getJsonKey(messageTypesList.TRANSCRIPT_TEXT);
ESP_LOGI(TAG, "BODY IS: %s", body);
#if ENABLEDISPLAY
displayLiveCaptions(body);
displayLiveCaptions(title, body);
#endif
}
} else if (!strcmp(messageType, messageTypesList.INTERMEDIATE_TRANSCRIPT)){
Expand All @@ -129,7 +129,8 @@ void eventDistributor(void *args){
char * body = (*jsonMessageParser).getJsonKey(messageTypesList.TRANSLATE_TEXT_RESULT_DATA);
//call display reference card here with title, body, image arguments
#if ENABLEDISPLAY
displaySearchEngineResult(title, body);
//displaySearchEngineResult(title, body);
displayLiveCaptions(title, body);
#endif
}
else if(!strcmp(messageType, messageTypesList.ACTION_SWITCH_MODES)){
Expand Down Expand Up @@ -193,7 +194,7 @@ void app_main(void)
//setup eventsDistributor and eventsBuffer, which handles incoming data from WIS and calls functions based on what WIS tells us to do
eventsBuffer = xMessageBufferCreate(eventsBufferLen);
TaskHandle_t eventsTask = NULL;
xTaskCreate(eventDistributor, "events_distribution_task", 6*1024, NULL, 1, &eventsTask);
xTaskCreate(eventDistributor, "events_distribution_task", 10*1024, NULL, 1, &eventsTask);

//connect to WIS web socket
websocketSendBuffer = xMessageBufferCreate(websocketSendBufferLen);
Expand Down

0 comments on commit ece51e5

Please sign in to comment.