Shop OBEX P1 Docs P2 Docs Learn Events
Enter ZIP — Parallax Forums

Enter ZIP

dondedonde Posts: 51
edited 2009-08-21 22:05 in Propeller 1
I'm very new to Prop, but have managed to get "Weather Internet Display", July, pg 15, Circuit Cellar, working OK on Propeller Demo Board, along with a W5100 Ethernet module. Getting WeatherBug data is based on entering your ZIP code into the program before compile. Then, weather for the ZIP shows up on screen. I can do this manually right now before loading Prop Tool. But, I want to do this interactively without plugging in PC

Coming in mail, is a programmed PIC to encode a common bus keypad. The circuit puts out 9600 baud serial ASCII data when a key is pressed. I have already played a demo serial program by Stefan, and I can see serial coming out from a string "Hello World". But I need to go the other way: RX data from the PIC. Right now the ZIP info is not in Main, so probably have to move it there where it loops, so it can ask for the ZIP, just once. To put in another ZIP, I would hit reset. I have no idea if loading EEPROM can be interrupted to input data and then continue to compile.

Probably my logic is not correct.
I guess I need to get some focus from someone on how to do all this!

Don

Comments

  • SRLMSRLM Posts: 5,045
    edited 2009-08-20 19:08
    No, the bootloader can't be interupted. But, you can write a small function to find the memory location that the zip is stored, and simply replace it. Worst case scenario, the zip is half written when the ZIP is needed by the internet interface, so it submits that and either gets an invalid data reply from the site or valid weather data for the wrong zip. Basically, what I'd do is add a label to the line that the zip code is on (maybe even break it onto it's own line), then a get function that returns the address of the label. Your main (or wherever you get your serial keypad data from) can then use the pointer to update the ZIP. You could even update it in the EEPROM for long term storage, although this would require an I2C object or function.

    BTW, for anybody else who reads this the link to code is here: ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2009/228/Nickels-228.zip
  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-20 19:09
    1) Loading EEPROM cannot be interrupted.

    2) You either have to compile the data into your program and download it or you have to write part of your program so it gets the data if it's not already there, then stores it in EEPROM.

    3) You can use something like FullDuplexSerialPlus from the Object Exchange to read data from a serial input line and either store it as a string (really a byte array) or convert the data to an integer. Look at the demo program included with FullDuplexSerialPlus.

    4) You can use something like Basic_I2C_Driver or any of several other I2C drivers in the Object Exchange to write one or more bytes to an otherwise unused portion of the EEPROM (and to read the bytes from there). This will remain untouched as long as you don't download a new program to the EEPROM. It gets erased to zeroes on a download. The Propeller Tool can show you how much EEPROM space your program uses (F8 key). The rest is available for this sort of data storage.
  • Agent420Agent420 Posts: 439
    edited 2009-08-20 19:22
    Don't know how it fits in the equation, but why not use a simple matrix keypad with the Prop rather than require another controller just for that purpose?

    Btw, the need to remember the zip data seems like a good use for the eeprom storage methods recently discussed here...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Post Edited (Agent420) : 8/20/2009 7:32:24 PM GMT
  • dondedonde Posts: 51
    edited 2009-08-21 18:04
    SLRM

    Well, I found the 3 memory locations where the 5 digit ZIP resides. All 3 ZIP's would be replaced to show new weather.

    1st one is at: 007C thru 0080
    2nd one is at: 0016 thru 011A
    3rd one is at: 01A6 thru 01AA

    Again, I want to send the 5 number (ZIP) into these 3 locations. Want to use a programmed PIC that puts out 9600 baud ASCII with a keypress. Still not sure of next coding step.
    Don
  • SRLMSRLM Posts: 5,045
    edited 2009-08-21 22:05
    So, now you'll want to check to see how many cogs are being utilized. If there is at least one free cog, then you're in luck. Otherwise, it will be more difficult to do what you want (you'd probably have to temporarily stop the display driver). I'll assume that there is a free cog. So, you'll add in a serial object (FullDuplexSerialPlus or some variant thereof would work) and start the serial to watch for the incoming data. You'll then make a method (probably in iwd2, but you'll want to confirm that) that simply calls the serial object and checks for the sort of data that you're looking for. If it isn't what you're looking for, then the method would exit to be called again sometime in the future. If the data is what you're looking for, you can copy byte by byte or as a string the five digits to a temporary array. Once you have the data in the array, call the bytemove function three times in order to copy the new zip (in ASCII) to each of the locations that you've found.

    PS: I'm glad that you noticed there was more that one place where the zip was. I only noticed one.
Sign In or Register to comment.