by parisse » 21 Sep 2020, 20:36
Ti64CLi++ wrote:Tu veux dire que pour simuler le on/off tu mettais le contrast au minimum ?
oui
Parce que dans ce cas là, juste écrire à 0x90130018 marche, je viens de tester sur ma CX II-T CAS
c'est bien ce que j'ai essaye de faire pourtant.
Mais c'est peut-etre le lcd controller qui pose probleme. Ce que je ne comprends pas c'est que le code suivant passait avec le precedent ndless mais pas avec celui-ci
- Code: Select all
int getkey(int allow_suspend){
sync_screen();
if (shutdown_state)
return KEY_SHUTDOWN;
int lastkey=-1;
unsigned NSPIRE_RTC_ADDR=0x90090000;
static unsigned lastt=0;
for (;;){
unsigned t1= * (volatile unsigned *) NSPIRE_RTC_ADDR;
if (lastt==0)
lastt=t1;
if (t1-lastt>10){
display_time();
sync_screen();
}
bool autosuspend=(t1-lastt>=100);
if (allow_suspend && (autosuspend || (nspire_ctrl && on_key_pressed()))){
nspire_ctrl=nspire_shift=false;
while (!autosuspend && on_key_pressed())
msleep(10);
// somewhat OFF by setting LCD to 0
unsigned NSPIRE_CONTRAST_ADDR=is_cx2?0x90130018:0x900f0020;
unsigned oldval=*(volatile unsigned *)NSPIRE_CONTRAST_ADDR;
*(volatile unsigned *)NSPIRE_CONTRAST_ADDR=0x100;
static volatile uint32_t *lcd_controller = (volatile uint32_t*) 0xC0000000;
lcd_controller[6] &= ~(0b1 << 11);
msleep(20);
lcd_controller[6] &= ~ 0b1;
unsigned offtime=* (volatile unsigned *) NSPIRE_RTC_ADDR;
for (int n=0;!on_key_pressed();++n){
msleep(100);
idle();
if (!exam_mode && shutdown
// && n&0xff==0
){
unsigned curtime=* (volatile unsigned *) NSPIRE_RTC_ADDR;
if (curtime-offtime>7200){
shutdown_state=1;
// after 2 hours, leave KhiCAS
// that way the OS will really shutdown the calc
lcd_controller[6] |= 0b1;
msleep(20);
lcd_controller[6]|= 0b1 << 11;
*(volatile unsigned *)NSPIRE_CONTRAST_ADDR=oldval;
statuslinemsg("Press ON to disable KhiCAS auto shutdown");
//os_fill_rect(0,0,320,222,0xffff);
sync_screen();
int m=0,mmax=150;
for (;m<mmax;++m){
if (on_key_pressed())
break;
msleep(100);
idle();
}
if (m==mmax){
if (shutdown())
return KEY_SHUTDOWN;
}
else {
shutdown_state=0;
break;
}
}
}
}
lcd_controller[6] |= 0b1;
msleep(20);
lcd_controller[6]|= 0b1 << 11;
*(volatile unsigned *)NSPIRE_CONTRAST_ADDR=oldval;
statusline(0);
sync_screen();
lastt=* (volatile unsigned *) NSPIRE_RTC_ADDR;
continue;
}