Skip to content

Commit

Permalink
Merge branch 'UpsilonNumworks:upsilon-dev' into superOS-master
Browse files Browse the repository at this point in the history
  • Loading branch information
AngeDieu authored Nov 4, 2023
2 parents 610dc2e + 7f2ba08 commit 7b62396
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 56 deletions.
5 changes: 5 additions & 0 deletions apps/apps_container_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ App::Snapshot * AppsContainerStorage::appSnapshotAtIndex(int index) {
};
assert(sizeof(snapshots)/sizeof(snapshots[0]) == k_numberOfCommonApps);
assert(index >= 0 && index < k_numberOfCommonApps);
// To avoid crashes, we return the home app snapshot if the index is out of
// bounds. (no crash in release mode, but an assert in debug mode)
if (index >= k_numberOfCommonApps) {
return snapshots[0];
}
return snapshots[index];
}

Expand Down
2 changes: 1 addition & 1 deletion bootloader/boot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void Boot::bootSlot(Bootloader::Slot s) {
if (!s.userlandHeader()->isOmega() && !s.userlandHeader()->isUpsilon()) {
// We are trying to boot epsilon, so we check the version and show an advertisement if needed
const char * version = s.userlandHeader()->version();
const char * min = "21.1.2";
const char * min = "21.3.1";
int versionSum = Utility::versionSum(version, strlen(version));
int minimalVersionTrigger = Utility::versionSum(min, strlen(min));
if (versionSum >= minimalVersionTrigger) {
Expand Down
2 changes: 1 addition & 1 deletion bootloader/interface/static/messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Messages {
constexpr static const char * aboutMessage4 = "and select the OS";
constexpr static const char * aboutMessage5 = "to boot.";

constexpr static const char * bootloaderVersion = "Version 1.0.6 - FREED0M.21.1";
constexpr static const char * bootloaderVersion = "Version 1.0.8 - FREED0M.21.3";

//USB NAMES
constexpr static const char * usbUpsilonBootloader = "Upsilon Bootloader";
Expand Down
23 changes: 4 additions & 19 deletions ion/src/simulator/nspire/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,10 @@ void quit() {
}

void draw() {
// copy framebuffer
const short unsigned int * ptr = (const short unsigned int *) Ion::Simulator::Framebuffer::address();
Gc * gcptr = get_gc();
for (int j = 0; j < LCD_HEIGHT_PX; ++j) {
for (int i = 0; i < LCD_WIDTH_PX;){
int c = *ptr;
int k = 1;
for (; k+i < LCD_WIDTH_PX; ++k) {
if (ptr[k]!=c) {
break;
}
}
gui_gc_setColor(*gcptr,c_rgb565to888(c));
gui_gc_drawRect(*gcptr,i,j,k-1,0);
ptr += k;
i += k;
}
}
sync_screen();
unsigned short * ionFramebuffer = (unsigned short *) Ion::Simulator::Framebuffer::address();
// we specify the screen fmt here because the "native" fmt varies between calculator revisions
// some default to a 240x320 specification, which results in a 90-degree framebuffer rotation and other terribleness.
lcd_blit(ionFramebuffer,SCR_320x240_565);
}

}
Expand Down
3 changes: 2 additions & 1 deletion ion/src/simulator/nspire/k_csdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ void statusline(int mode){
#include "k_defs.h"

void sdk_init(void){
lcd_init(lcd_type()); // clrscr();
lcd_init(lcd_type());
}

void sdk_end(void){
Expand Down Expand Up @@ -993,6 +993,7 @@ int nspire_shift=0;
int nspire_ctrl=0;
int nspire_select=false;
void statusline(int mode){
return; //this is broken for our purposes and it honestly doesn't matter enough to fix.
char *msg=0;
if (nspire_ctrl){
if (nspire_shift)
Expand Down
3 changes: 3 additions & 0 deletions ion/src/simulator/nspire/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ State scan() {
return state;
}
}
if (isKeyPressed(KEY_NSPIRE_TENX)){
exit(0);
}
return state;
}

Expand Down
31 changes: 1 addition & 30 deletions ion/src/simulator/nspire/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extern "C" {
int calculator=4; // -1 means OS not checked, 0 unknown, 1 cg50 or 90, 2 emu 50 or 90, 3 other

int main() {
sdk_init();
sdk_init(); //this calls the lcd init functions from behind the scenes
Ion::Simulator::Main::init();
ion_main(0, NULL);
Ion::Simulator::Main::quit();
Expand Down Expand Up @@ -63,35 +63,6 @@ void quit() {
Ion::Simulator::Display::quit();
}

void runPowerOffSafe(void (*powerOffSafeFunction)(), bool prepareVRAM) {
// somewhat OFF by setting LCD to 0
unsigned NSPIRE_CONTRAST_ADDR=is_cx2?0x90130014:0x900f0020;
unsigned oldval=*(volatile unsigned *)NSPIRE_CONTRAST_ADDR,oldval2;
if (is_cx2){
oldval2=*(volatile unsigned *) (NSPIRE_CONTRAST_ADDR+4);
*(volatile unsigned *) (NSPIRE_CONTRAST_ADDR+4)=0xffff;
}
*(volatile unsigned *)NSPIRE_CONTRAST_ADDR=is_cx2?0xffff:0x100;
static volatile uint32_t *lcd_controller = (volatile uint32_t*) 0xC0000000;
lcd_controller[6] &= ~(0b1 << 11);
loopsleep(20);
lcd_controller[6] &= ~ 0b1;
unsigned NSPIRE_RTC_ADDR=0x90090000;
unsigned offtime=* (volatile unsigned *) NSPIRE_RTC_ADDR;
for (int n=0;!on_key_pressed();++n){
loopsleep(100);
idle();
}
lcd_controller[6] |= 0b1;
loopsleep(20);
lcd_controller[6]|= 0b1 << 11;
if (is_cx2)
*(volatile unsigned *)(NSPIRE_CONTRAST_ADDR+4)=oldval2;
*(volatile unsigned *)NSPIRE_CONTRAST_ADDR=oldval;
sync_screen();

}

}
}
}
2 changes: 0 additions & 2 deletions ion/src/simulator/nspire/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ void quit();
void setNeedsRefresh();
void refresh();

void runPowerOffSafe(void (*powerOffSafeFunction)(), bool prepareVRAM);

}
}
}
Expand Down
8 changes: 6 additions & 2 deletions ion/src/simulator/nspire/power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ void powerOff(void){
namespace Ion {
namespace Power {

//NOTE: These should probably be reimplemented at some point
//the prior version was a janky mess that flickered a ton on wake
//and was generally awfulness.

void suspend(bool checkIfOnOffKeyReleased) {
Simulator::Main::runPowerOffSafe(powerOff, true);
// Simulator::Main::runPowerOffSafe(powerOff, true);
}

void standby() {
Simulator::Main::runPowerOffSafe(powerOff, true);
// Simulator::Main::runPowerOffSafe(powerOff, true);
}

}
Expand Down
5 changes: 5 additions & 0 deletions python/port/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ void micropython_port_vm_hook_refresh_print() {
}

bool micropython_port_interruptible_msleep(int32_t delay) {
// Check if the user entered a bad delay (negative)
if (delay < 0) {
return false;
}

assert(delay >= 0);
/* We don't use millis because the systick drifts when changing the HCLK
* frequency. */
Expand Down

0 comments on commit 7b62396

Please sign in to comment.