Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 05:43 02 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Test AUTORUN setting?

Author Message
Justplayin

Guru

Joined: 31/01/2014
Location: United States
Posts: 327
Posted: 10:09am 18 Apr 2016
Copy link to clipboard 
Print this post

Is there a way for a program check if AUTORUN has been set? OPTION LIST will show if has be set, but I don't see a way to capture the result of that query.

--Curtis
I am not a Mad Scientist...  It makes me happy inventing new ways to take over the world!!
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1427
Posted: 10:52am 18 Apr 2016
Copy link to clipboard 
Print this post

I wish that all of the OPTION LIST items were testable. I asked for this, but it never happened.

It would be nice to know - in the program - if the touch was configured, too.

Even A = OPTION LIST where A is set to a value where the bit positions represented options. b0 equal to 1 would be AUTORUN is on, b1-b3 would be LCD display type, etc.

Or a PEEK? Is there a PEEK for this?


Micromites and Maximites! - Beginning Maximite
 
Justplayin

Guru

Joined: 31/01/2014
Location: United States
Posts: 327
Posted: 12:01pm 18 Apr 2016
Copy link to clipboard 
Print this post

Another thing I'd like to test for is if a supported RTC is present. Since it is a fatal error if is not, it would be nice to know before trying to access it. Just had one of my RTC modules fail, it would have be nice if the software could have simply failed over to the internal clock instead of crashing.

--Curtis
I am not a Mad Scientist...  It makes me happy inventing new ways to take over the world!!
 
Zonker

Guru

Joined: 18/08/2012
Location: United States
Posts: 767
Posted: 12:10pm 18 Apr 2016
Copy link to clipboard 
Print this post

Maybe a Cfunction to do this..?
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3281
Posted: 03:32pm 18 Apr 2016
Copy link to clipboard 
Print this post

As it happens, the option table is one of the few places in MMBasic where PEEK() is useful. To discover the AUTORUN setting you can use:
peek(byte peek(word &H9D000090))
This will return 1 if AUTORUN is ON or 0 if it is OFF

Other things that you can discover are:
The current display type
peek(byte peek(word &H9D000090) + 20)
where:
No Display = 0
SSD1963_4 = 1
SSD1963_5 = 2
SSD1963_5A = 3
SSD1963_7 = 4
SSD1963_7A = 5
SSD1963_8 = 6
ILI9341 = 7
ILI9163 = 8
ST7735 = 9

The display orientation (1 = landscape, 2 = portrait, 3 = RevL, 4 = RevP)
peek(byte peek(word &H9D000090) + 21)

The I/O pin used for touch CS (zero means that touch is not configured)
peek(byte peek(word &H9D000090) + 22)

The I/O pin used for touch INT (handy if you want to set an interrupt on touch)
peek(byte peek(word &H9D000090) + 23)

Is the touch calibrated? Zero means no, non zero yes.
peek(word peek(word &H9D000090) + 28)

The I/O pin used for the LCD CS (zero means that the LCD is not configured)
peek(byte peek(word &H9D000090) + 45)

The I/O pin used for the LCD CD
peek(byte peek(word &H9D000090) + 44)

The I/O pin used for the LCD reset
peek(byte peek(word &H9D000090) + 46)

The I/O pin used for the SD card CS (zero means that the SD card is not configured)
peek(byte peek(word &H9D000090) + 48)

What MMBasic thinks is the width of the console in characters
peek(byte peek(word &H9D000090) + 5)

What MMBasic thinks is the height of the console in lines
peek(byte peek(word &H9D000090) + 4)

These work on all versions after 5.0 and for both the MX170 and MX470 variants. Also, they will not change in future versions of the Micromite firmware.


  Justplayin said   Another thing I'd like to test for is if a supported RTC is present. Since it is a fatal error if is not, it would be nice to know before trying to access it. Just had one of my RTC modules fail, it would have be nice if the software could have simply failed over to the internal clock instead of crashing

You can do this with the following code in BASIC:
' test if the RTC is present
I2C Open 100, 200, PU
I2C Write &H68, 0, 1, 0
If MM.I2C <> 0 Then I2C Write &H51, 0, 1, 2
If MM.I2C = 0 Then
' Yes, the RTC is present
RTC GetTime
If Date$ = "01-01-2000" Then Print "RTC has invalid date and time"
Else
' RTC not found
Print "No RTC found, time is not set"
EndIf



Geoff Graham - http://geoffg.net
 
Justplayin

Guru

Joined: 31/01/2014
Location: United States
Posts: 327
Posted: 03:55pm 18 Apr 2016
Copy link to clipboard 
Print this post

Thank you Geoff! You made me very happy, and I'm sure a number of other people will also be glad to see this handy/useful information!

--CurtisEdited by Justplayin 2016-04-20
I am not a Mad Scientist...  It makes me happy inventing new ways to take over the world!!
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025