Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update lamp test to not show on menu for unimplemented hosts #9

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Altair8800.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1662,8 +1662,10 @@ void setup()

// if EXAMINE switch is held up during powerup then show host system info
if( host_read_function_switch(SW_EXAMINE) )
{
host_system_info();

host_lamp_test(1);
}
// emulator extra: holding down CLR at powerup will keep all registers
// and memory content initialized with 0. Otherwise (as would be normal
// with the Altair), everything is random.
Expand Down
5 changes: 4 additions & 1 deletion config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3102,6 +3102,7 @@ void config_edit()
Serial.print(F("Pro(c)essor : ")); print_cpu(); Serial.println(); r_cpu = row++;
#endif
Serial.print(F("Aux1 shortcut program (u/U) : ")); print_aux1_program(); Serial.println(); r_aux1 = row++;
if (host_lamp_test(0)) { Serial.print(F("Lamp test (*)")); Serial.println(); row++; }
Serial.print(F("Configure host (s)erial : "));
#if HOST_NUM_SERIAL_PORTS>1
Serial.print(F("Primary: "));
Expand All @@ -3119,7 +3120,6 @@ void config_edit()
row+=2;
Serial.println();
Serial.print(F("(E) Configure serial cards : ")); print_mapped_serial_cards(); Serial.println(F(" mapped")); row++;

#if USE_PRINTER>0
Serial.print(F("(P) Configure printer : "));
print_printer_type();
Expand Down Expand Up @@ -3171,6 +3171,9 @@ void config_edit()
redraw = true;
switch( c )
{
case '*':
host_lamp_test(1);
break;
#if USE_Z80==2
case 'c':
config_flags2 = toggle_bits(config_flags2, 21, 1);
Expand Down
1 change: 1 addition & 0 deletions host.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ void host_storage_invalidate();
// miscellaneous
void host_copy_flash_to_ram(void *dst, const void *src, uint32_t len);
uint32_t host_get_random();
int host_lamp_test(int); // 0 for test if implemented (returns 1); 1 for test lamps (returns 0) ;
void host_system_info();
void host_setup();

Expand Down
34 changes: 33 additions & 1 deletion host_due.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ const char *host_filesys_dir_nextfile(File &d)
{
if( entry.isFile() )
{
entry.getSFN(buffer);
entry.getSFN(buffer,sizeof(buffer));
entry.close();
return buffer;
}
Expand Down Expand Up @@ -1752,6 +1752,38 @@ uint32_t host_get_random()
return (uint32_t) trng_read_output_data(TRNG);
}

static uint32_t lamppins[]=
{ 12, 13, 9, 8, 7, 6, 5, 4, 3, 2, 11, 29, 15, 14, 28, 27, 26, 25, 10, 22, 44, 45, 46, 47, 48, 49, 50, 51, 41, 40, 39, 38, 37, 36, 35, 34 }; // DUE

#define LAMPCT (sizeof(lamppins)/sizeof(lamppins[0]))

int host_lamp_test(int cmd)
{
unsigned i,j=0;
int lastpin=-1;
if (cmd==0) return 1;
Serial.println();
Serial.println("Lamp test in progress...");
for (i=0;i<LAMPCT;i++) // all on
digitalWrite(lamppins[i],HIGH);
delay(10000); // 10s
for (i=0;i<LAMPCT;i++) // all off
digitalWrite(lamppins[i],LOW);
for (i=0;i<LAMPCT*2;i++) // go forward and backward
{
if (lastpin!=-1) digitalWrite(lamppins[lastpin],LOW); // turn off last light
if (j==LAMPCT) j--; // adjust for bounce at the end
digitalWrite(lamppins[j],HIGH); // light it up
lastpin=j; // remember which one to turn off next time
if (i>=LAMPCT) j--; else j++; // left or right
delay(250);
}
digitalWrite(lamppins[0],LOW); // turn off the last one
// good place to stick one or more on for extended troubleshooting
//digitalWrite(44,HIGH);
return 0;
}


#include <malloc.h>
extern char _end;
Expand Down
1 change: 1 addition & 0 deletions host_mega.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ void host_system_info()
Serial.print(F("Free RAM : ")); Serial.println(SP - heapend);
}

int host_lamp_test(int cmd) { return 0; };

void host_setup()
{
Expand Down
2 changes: 2 additions & 0 deletions host_pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,8 @@ bool host_serial_port_has_configs(byte i)
return false;
}

int host_lamp_test(int cmd) { return 0; };


// ----------------------------------------------------------------------------------------------------

Expand Down
2 changes: 2 additions & 0 deletions host_teensy36.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ bool host_filesys_ok()
return use_sd;
}

int host_lamp_test(int cmd) { return 0; };


//------------------------------------------------------------------------------------------------------

Expand Down