![]() |
Forum Index : Microcontroller and PC projects : Pi-cromite 5.04.17: Sprites
![]() ![]() |
|||||
Author | Message | ||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
It is using the system time so if the pi is online it will have been updated from an ntp server |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Peter There's still one bug that's causing the scrolling display I tested the Pi the other day and left it connected to the power today I connected to the Pi ran sudo ./mmbasic I go the scrolling text Would it be because mmbasic was already running on the Pi and when I try and run it again it's doing this? |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
Yes. You should always exit the Pi-cromite application (ctrl-Z) before disconnecting the terminal. There is a way of connecting the Pi-cromite application to a pseudo-terminal such that you can then re-connect to the same instance later. Details for this were supplied buy another TBS member and are buried somewhere in the original very long Pi-cromite thread |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Thanks Peter ![]() Another question if you don't mind I've got the data coming from DarkSky perfectly now but I can't figure out how to assign it I'm hopeless at trying to explain but With MM and serial input I could use temp2$ = WData$(2) 'temp tomorrow WData$(2) was the 3rd comma seperated character With the Picromit I'm using what's in the manual ? JSON$(a(),"currently.icon"), "ICON$" It works but I cannot use ICON$ later in the program Is there a way to make it similar to ICON$ = ? JSON$(a(),"currently.icon") or ? JSON$(a(),"currently.icon"), = "ICON$" |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
icon$=JSON$(a(),"currently.icon"):? icon$ |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Thanks Peter, you're a star ![]() |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Could anyone tell me why this works with Darksky* [code]icon$=JSON$(a(),"currently.icon"):? icon$ PRINT icon$ [/code] But does not work with Openweathermap?* [code]icon3$=JSON$(b(),"icon"):? icon3$ PRINT icon3$ [/code] I've tried all variations I can think of including JSON$(b%() as per the manual and I've also tried main.icon |
||||
disco4now![]() Guru ![]() Joined: 18/12/2014 Location: AustraliaPosts: 1003 |
Assuming your have captured the data into b%() then the following should pull the icon value from the returned data. This should be for the forecast query and to get day 0 is list[0] day 1 is list[1] etc. icon3$=JSON$(b%(),”list[0].weather[0].icon") This is for current weather query icon$=JSON$(b%(),“weather[0].icon”) If you put the query into your browser and look at the returned data helps work out it structure and what the key values need to be. Regards Gerry Latest F4 Latest H7 FotS |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
Not sure if this is a bug or if it needs to be called something else but when I try and call a function it says Function Atan2(x,y) Error: Invalid identifier the code works on the normal MM |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
Atan2 is a built-in function in the MMX and Pi-cromite. Just delete your Basic version |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
oh nice, thanks Peter |
||||
lizby Guru ![]() Joined: 17/05/2016 Location: United StatesPosts: 3378 |
I'm trying to write to a 24LC64 eeprom with Pi-cromite mmbasic on a pi zero w. I don't clearly see how to specify the address to be written, but in this thread, grogster, et. al., put in the address bytes before the bytes to be written: Dim A=1 'Address byte ... I2C WRITE &B1010000,0,6,A\256,A Mod 256,B,C,D,E 'Write four bytes from address 1 I'm trying to write a 4K+ character file with this code. [code] ' write 24LC64 eeprom ' option i2c 3,5 ' not valid within a program open "watermon_chart.html.template" for input as 1 dim as string A dim as integer i = 0, iflag = 0 CONST cFE=chr$(254) CONST cFF=chr$(255) i2c open 100,100 do A = input$(16,1) ? A if len(A) <> 16 then A = A + cFE + cFE + cFE + cFE + cFE + cFE + cFE + cFE + cFE + cFE + cFE + cFE + cFE + cFE + cFE + cFE A = mid$(A,1,16) ' truncate to 16 characters iflag = 1 endif i2c write &H50,0,18,i\256,i Mod 256,A ' write 2 address bytes and 16 data bytes Pause 10 'make sure EEPROM has time to write(5ms needed) i = i + len(A) if iflag = 1 then exit endif loop close 1 ? i [/code] I'm reading (and writing) 16 bytes at a time, and if the last read is less than 16 bytes, filling in with 0xFE. The error message on the first write says "Error: Argument count". ![]() (I had to enter "OPTION I2C 3,5" at an MMBASIC ">" prompt to get past an objection that the I2C pins weren't defined--are all pins available with picromite i2c?) How do I specify an address to be written for the eeprom? PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
Your syntax is incorrect - check the Micromite manual Appendix B. You can either have a list of single variables or an array/string not both. Yes, the I/F is bitbanged as the Pi has known issues with clock stretching and the bitbang code does this properly |
||||
lizby Guru ![]() Joined: 17/05/2016 Location: United StatesPosts: 3378 |
Thank you. This worked: A = chr$(i\256)+chr$(i Mod 256)+A i2c write &H50,0,18,A ' write 2 address bytes and 16 data bytes 4144 bytes written. At long last: a convenient way to write bulk data to an 8-pin eeprom. PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed |
||||
disco4now![]() Guru ![]() Joined: 18/12/2014 Location: AustraliaPosts: 1003 |
Hi Peter, I would like any suggestions you might have for the following situation. I am using the SYSTEM call below on a Pi-cromite to display weather information. It works quite well, but every so often the thing stops updating at random times. e.g after about 2000 calls and 4,000 calls the last two times. This is over 3-4 days. I opened up another terminal and can see two 'sh' processes, the first issued from mmbasic and then the second that is running the desired command. So there is some obscure situation where 'wget' never finishes, so mmbasic waits forever. I have played with OPTION AUTORUN ON and killing the second 'sh' process will then cause MMbasic to restart and run the program. (The program name must be AUTORUN.BAS, the manual incorrectly say is should be autorun.bas (lower case)) I have tried WATCHDOG in the MMbasic code but I don't think it is implemented, it gives no errors but does not seem to do anything. The MM.WATCHDOG variable is not allowed with OPTION EXPLICIT. I tried calling CPU RESTART from a SETTICK timer but it does not seem to work when the SYSTEM command is waiting,(interrupts not allowed here?) but works OK if its just a DO:LOOP holding it up. A CRON job at the linux level killing off the hung 'su' process at regular intervals would probably work but I have not tried it yet. Some nicer options I can think of but might be not doable. a) an extra optional timeout parameter on the SYSTEM call b) WATCHDOG functionality I am using the following to simulate the non returning SYSTEM call SYSTEM "sh" Any thoughts, Regards Gerry Latest F4 Latest H7 FotS |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
Can you use the TCP CLIENT command rather than SYSTEM? Then you can receive the data using non-blocking TCP RECEIVE. See this thread |
||||
disco4now![]() Guru ![]() Joined: 18/12/2014 Location: AustraliaPosts: 1003 |
The API only supports HTTPS:// so I am using SYSTEM to shell the linux WGET that supports it. I think I might be making some progress toward starting a background process that will kill a hung WGET. Is WATCHDOG supposed to work? Thanks Gerry Latest F4 Latest H7 FotS |
||||
MikeO Senior Member ![]() Joined: 11/09/2011 Location: AustraliaPosts: 275 |
Possible solution? I tried using Curl instead of wget, seems to work OK, advantage is that it has a timeout parameter. dim integer a(1000) system "curl http://api.wunderground.com/api/yourKey/conditions/q/AU/Melbourne.json -m 60",a() for i=1 to llen(a()) print lgetstr$(a(),i,1); next i I used wunderground as my darksky API has run out and they seems to want CR card these days? any way principle is same. I loaded Curl to Pi Zero with this info Codenquilts |
||||
disco4now![]() Guru ![]() Joined: 18/12/2014 Location: AustraliaPosts: 1003 |
Thanks Mike. curl could be a good option. Gerry Latest F4 Latest H7 FotS |
||||
![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |