Skip to content

Commit

Permalink
If battery reports full, assume 100%. If the bot was charging and is …
Browse files Browse the repository at this point in the history
…now disconnected, remove charging bolt.
  • Loading branch information
kercre123 committed Nov 7, 2024
1 parent cf768c9 commit 047bbf8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
28 changes: 15 additions & 13 deletions chipper/pkg/vars/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,21 @@ type apiConfig struct {
Unit string `json:"unit"`
} `json:"weather"`
Knowledge struct {
Enable bool `json:"enable"`
Provider string `json:"provider"`
Key string `json:"key"`
ID string `json:"id"`
Model string `json:"model"`
IntentGraph bool `json:"intentgraph"`
RobotName string `json:"robotName"`
OpenAIPrompt string `json:"openai_prompt"`
OpenAIVoice string `json:"openai_voice"`
OpenAIVoiceWithEnglish bool `json:"openai_voice_with_english"`
SaveChat bool `json:"save_chat"`
CommandsEnable bool `json:"commands_enable"`
Endpoint string `json:"endpoint"`
Enable bool `json:"enable"`
Provider string `json:"provider"`
Key string `json:"key"`
ID string `json:"id"`
Model string `json:"model"`
IntentGraph bool `json:"intentgraph"`
RobotName string `json:"robotName"`
OpenAIPrompt string `json:"openai_prompt"`
OpenAIVoice string `json:"openai_voice"`
OpenAIVoiceWithEnglish bool `json:"openai_voice_with_english"`
SaveChat bool `json:"save_chat"`
CommandsEnable bool `json:"commands_enable"`
Endpoint string `json:"endpoint"`
TopP float32 `json:"top_p"`
Temperature float32 `json:"temp"`
} `json:"knowledge"`
STT struct {
Service string `json:"provider"`
Expand Down
6 changes: 3 additions & 3 deletions chipper/pkg/wirepod/setup/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ func SetupBotViaSSH(ip string, key []byte) error {
}
}
} else {
resp, _ := http.Get("https://github.com/kercre123/wire-pod/raw/main/vector-cloud/build/vic-cloud")
resp, err := http.Get("https://github.com/kercre123/wire-pod/raw/main/vector-cloud/build/vic-cloud")
if err != nil {
return doErr(err, "transferring new vic-cloud")
return doErr(err, "transferring new vic-cloud (download)")
}
SetupSSHStatus = "Transferring new vic-cloud..."
scpClient, err = scp.NewClientBySSH(client)
Expand Down Expand Up @@ -228,7 +228,7 @@ func SSHSetup(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "error: must provide ssh key ("+err.Error()+")")
return
}
keyBytes, _ := io.ReadAll(key)
keyBytes, err := io.ReadAll(key)
if len(keyBytes) < 5 {
fmt.Fprint(w, "error: must provide ssh key ("+err.Error()+")")
return
Expand Down
6 changes: 6 additions & 0 deletions chipper/webroot/js/battery.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ async function updateBatteryInfo(serial, i) {
// Do nothing
}
if (!batteryStatus) {
if (charging) {
charging.remove();
}
batteryLevel.className = "batteryLevel batteryUnknown";
vectorFace.style.backgroundImage = "url(/assets/wififace.gif)";
tooltip.innerHTML = `<b>${serial}</b><br/>??%<br/> (Unable to connect)`;
Expand All @@ -77,6 +80,7 @@ async function updateBatteryInfo(serial, i) {
batteryStatus["battery_level"] = 0; // Set color to red
}


// Set the battery level based on the battery_level value and handle the rest in css
const batteryLevelClass = "batteryLevel battery" + batteryStatus["battery_level"];
if (batteryLevel.className !== batteryLevelClass) {
Expand Down Expand Up @@ -105,6 +109,8 @@ async function updateBatteryInfo(serial, i) {
chargeTimeRemaining.innerHTML = "";
}else {
chargeTimeRemaining.innerHTML = "Full";
// assume 100% if Full
batteryLevel.style.width = "100%";
vectorFace.style.backgroundImage = "url(/assets/face.gif)";
}
} else {
Expand Down

0 comments on commit 047bbf8

Please sign in to comment.