Extreme optimize + bug fixes + prerendering fix + more deprecation
Some checks failed
Rebuild signaller for deprived.dev to rebuild site / test_service (push) Failing after 1s
Some checks failed
Rebuild signaller for deprived.dev to rebuild site / test_service (push) Failing after 1s
This commit is contained in:
parent
28eea2d035
commit
4e2fe3700d
53 changed files with 324 additions and 1775 deletions
123
deprecated/tools/battery-life-calculator/pageSrc/BatteryCalc.ts
Normal file
123
deprecated/tools/battery-life-calculator/pageSrc/BatteryCalc.ts
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
export class BatteryLifeCalculator {
|
||||
timeRunSeconds: number;
|
||||
timeSleepSeconds: number;
|
||||
consumptionActiveMilliAmpHours: number;
|
||||
consumptionSleepMilliAmpHours: number;
|
||||
powerBatteryTotalMilliAmpHours: number;
|
||||
powerBatteryBufferBeforeEmptyPercent: number;
|
||||
|
||||
constructor(
|
||||
timeRunSeconds: number,
|
||||
timeSleepSeconds: number,
|
||||
consumptionActiveMilliAmpHours: number,
|
||||
consumptionSleepMilliAmpHours: number,
|
||||
powerBatteryTotalMilliAmpHours: number,
|
||||
powerBatteryBufferBeforeEmptyPercent: number = 20
|
||||
) {
|
||||
this.timeRunSeconds = timeRunSeconds;
|
||||
this.timeSleepSeconds = timeSleepSeconds;
|
||||
this.consumptionActiveMilliAmpHours = consumptionActiveMilliAmpHours;
|
||||
this.consumptionSleepMilliAmpHours = consumptionSleepMilliAmpHours;
|
||||
this.powerBatteryTotalMilliAmpHours = powerBatteryTotalMilliAmpHours;
|
||||
this.powerBatteryBufferBeforeEmptyPercent = powerBatteryBufferBeforeEmptyPercent;
|
||||
|
||||
console.log(
|
||||
"The source of this battery calc is here: https://github.com/simonneutert/batterylife-calculator\nI was too lazy to make the math myself."
|
||||
);
|
||||
}
|
||||
|
||||
// public API
|
||||
|
||||
milliAmpToMicroAmp(milliAmps: number): number {
|
||||
return milliAmps * 1000;
|
||||
}
|
||||
|
||||
microAmpToMilliAmp(milliAmps: number): number {
|
||||
return milliAmps * 0.001;
|
||||
}
|
||||
|
||||
calculate(): {
|
||||
powerAveragePerHour: number;
|
||||
runtimeHoursEstimated: number;
|
||||
runtimeDaysEstimated: number;
|
||||
runtimeDaysRemainingHoursEstimated: number;
|
||||
} {
|
||||
return {
|
||||
powerAveragePerHour: this.powerEstimatedHourly(),
|
||||
runtimeHoursEstimated: this.runtimeHoursEstimated(),
|
||||
runtimeDaysEstimated: this.runtimeDaysEstimated(),
|
||||
runtimeDaysRemainingHoursEstimated: this.runtimeDaysRemainingHoursEstimated(),
|
||||
};
|
||||
}
|
||||
|
||||
powerEstimatedHourly(): number {
|
||||
return this.calcPowerEst(
|
||||
this.powerRun(),
|
||||
this.consumptionActiveMilliAmpHours,
|
||||
this.powerSleep(),
|
||||
this.consumptionSleepMilliAmpHours
|
||||
);
|
||||
}
|
||||
|
||||
runtimeHoursEstimated(): number {
|
||||
return parseInt((this.powerLipo() / this.powerEstimatedHourly()).toString(), 10);
|
||||
}
|
||||
|
||||
runtimeDaysEstimated(): number {
|
||||
return parseInt((this.runtimeHoursEstimated() / 24).toString(), 10);
|
||||
}
|
||||
|
||||
runtimeDaysRemainingHoursEstimated(): number {
|
||||
return parseInt((this.runtimeHoursEstimated() % 24).toString(), 10);
|
||||
}
|
||||
|
||||
// private methods
|
||||
|
||||
private roundOff(x: number): number {
|
||||
return Math.round(x * 100.0) / 100.0;
|
||||
}
|
||||
|
||||
private calcPowerLipo(x: number, y: number): number {
|
||||
return parseFloat(((x * (100 - y)) / 100).toString());
|
||||
}
|
||||
|
||||
private calcRuns(x: number, y: number): number {
|
||||
return parseFloat((60 / (x + y)).toString());
|
||||
}
|
||||
|
||||
private calcRunsHour(x: number, y: number): number {
|
||||
return parseFloat((3600 / (x + y)).toString());
|
||||
}
|
||||
|
||||
private calcPowerRun(x: number, y: number): number {
|
||||
return parseFloat(((x / (x + y)) * 3600).toString());
|
||||
}
|
||||
|
||||
private calcPowerSleep(x: number, y: number): number {
|
||||
return parseFloat(((y / (x + y)) * 3600).toString());
|
||||
}
|
||||
|
||||
powerLipo(): number {
|
||||
return this.calcPowerLipo(this.powerBatteryTotalMilliAmpHours, this.powerBatteryBufferBeforeEmptyPercent);
|
||||
}
|
||||
|
||||
runs(): number {
|
||||
return this.calcRuns(this.timeRunSeconds, this.timeSleepSeconds);
|
||||
}
|
||||
|
||||
runsHour(): number {
|
||||
return this.calcRunsHour(this.timeRunSeconds, this.timeSleepSeconds);
|
||||
}
|
||||
|
||||
powerRun(): number {
|
||||
return this.calcPowerRun(this.timeRunSeconds, this.timeSleepSeconds);
|
||||
}
|
||||
|
||||
powerSleep(): number {
|
||||
return this.calcPowerSleep(this.timeRunSeconds, this.timeSleepSeconds);
|
||||
}
|
||||
|
||||
private calcPowerEst(a: number, b: number, c: number, d: number): number {
|
||||
return parseFloat(((a / 3600) * b + (c / 3600) * d).toString());
|
||||
}
|
||||
}
|
||||
63
deprecated/tools/battery-life-calculator/pageSrc/MCU_defs.ts
Normal file
63
deprecated/tools/battery-life-calculator/pageSrc/MCU_defs.ts
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
export interface MCU_Type {
|
||||
name: string;
|
||||
cpu: { [key: string]: Number }; // state: power consumption
|
||||
sleep: { [key: string]: Number };
|
||||
wifi?: { [key: string]: Number };
|
||||
bluetooth?: { [key: string]: Number };
|
||||
}
|
||||
|
||||
const MCUs: MCU_Type[] = [
|
||||
{
|
||||
name: "esp32-s3",
|
||||
cpu: { // mili amps
|
||||
single_core_40MHz: 21.8,
|
||||
dual_core_40MHz: 24.4,
|
||||
single_core_80MHz: 42.6,
|
||||
dual_core_80MHz: 47.3,
|
||||
single_core_160MHz: 54.6,
|
||||
dual_core_160MHz: 54.1,
|
||||
single_core_240MHz: 65.9,
|
||||
dual_core_240MHz: 81.3,
|
||||
},
|
||||
sleep: {
|
||||
|
||||
},
|
||||
wifi: { //
|
||||
dBm_21: 318.2,
|
||||
sleep: 10
|
||||
},
|
||||
bluetooth: {
|
||||
active: 100,
|
||||
sleep: 5
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
name: "esp32-c3",
|
||||
cpu: {
|
||||
single_core_80MHz: 22,
|
||||
single_core_160MHz: 54.6,
|
||||
},
|
||||
sleep: {
|
||||
|
||||
},
|
||||
wifi: {
|
||||
active: 110,
|
||||
sleep: 9
|
||||
},
|
||||
bluetooth: {
|
||||
active: 90,
|
||||
sleep: 4
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
export function getMCU(name: string): MCU_Type | undefined{
|
||||
for (let i = 0; i < MCUs.length; i++) {
|
||||
const element = MCUs[i];
|
||||
if (element.name == name)
|
||||
return element
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue