Chat_pt code

@JonnyMac
@"Stephen Moraco"
@cgracey
@"Ken Gracey"
Howdy.
I tried the chat pt. Asked it to write some code in spin 1 for the erm12864-2 display that I got when we were in Sacramento a few months ago.
It was interesting that it wrote some coherent code. As JonnyMac said it needed tweeking.
What I found using spin tools ide which was nice enough to show error immediately, Kudos,
that in part of the code variables like:
PIN_RS = 0
were good until it got to some PRI methods.
PRI chipData(chip, v)
high PIN_RS ' RS=1 for data
low PIN_RW ' RW=0 for write
selectChip(chip)
writeBus(v)
pulseE
deselect
Both the Pin_RS and _RW were rejected as errors says "unexpected"
I will be messing around with this for fun.
Any suggestions are appreciated. Propeller tool says the same. At first glance it should run.
I got some insight as to code that may work, thanks for the suggestion Jonnymac.
Looking forward for the next zoom meeting about using the chat boxes for help.
Thanks
Martin
Code is attached.
Comments
I have found that there is enough P2 code out now that the AIs seem to interject P2-ish stuff into P1 code. In my experiments, claude.ai seems to be a little better. The code above has lots of errors, but that's usually how these things go. This is why I often tell the AI to create generic code that I can run on any microcontroller (with bit-banged SPI) and I clean it up from there.
For this experiment, though, I requested Spin1 code. First prompt:
I would like Spin1 code for the Parallax Propeller P1 for the ERM12864-2 display. Where required, use my jm_time.spin library for delays, and my jm_io.spin for basic IO control of pins.
At first blush the code looks pretty good but uses a ternary operator (which the P2 has, but the P1 doesn't) so it won't compile. Second prompt:
The code won't compile with Spin1 because you've used a ternary operator. Please correct that. Also, section identifiers (pub, pri, dat, etc.) should be in lowercase, with a blank line after the declaration, and two blank lines before a declaration.
I forgot that my time object has the speed in the name, and the ai-generated code has a bad method name. Third prompt.
Sorry, the correct library name is jm_time_80.spin and the method for delays in milliseconds is pause(), not pause_ms().
The third version of the program compiles without errors, but I don't know if it works. The next step would be two connect things and try it, then go back to the AI as needed.
For the last version I've attached an archive so that anyone trying this has my libraries. Note that there are still style issues in the code -- but that's a personal preference. In past sessions I have told claude how I like to style my code, but those rules don't seem to stick.
Link to session: https://claude.ai/share/0d29144b-2831-4558-aacc-be7a6d574a7c
It appears to be an adventure.
Thanks I will look at the code. Plus a bit of a laugh at AI.
Martin
Swing and a miss. I tried to be very generic with claude.ai and it provided SPI code, where your device seems to have a parallel interface.
So, I tried Grok -- and not really thrilled. Prompt:
I have a ERM12864-2 display with a parallel bus. Please show me how to write Propeller 1 (Spin1) code to control this display.
Interestingly, Grok showed what was happening as it was "thinking." It even displayed this at one point.

The code output is not formatted at all, and there were two syntax errors that required fixing before it would compile at all. Since the code was short I manually reformatted it and turned it from a demo into an object. I don't know if it will work.
Went back to claude.ai with a better prompt.
I have a ERM12864-2 display with a parallel bus. Please show me how to write Propeller 1 (Spin1) code to control this display. Please use my (Jon McPhalen) coding style for the P1.
The code compiled the first time but had errors. Part of the process is giving feedback to the AI. You can see that in the chat:
-- https://claude.ai/share/38e394c6-0275-44fe-a7e9-d4782758f0a1
It took about five iterations before it looked like it would run without problems, but without hardware I have know way to verify.
Quite an interesting adventure.
I will solder pins in the screen and try all of this out. Interesting that one has to coax the AI. I think the AI also has memory for previous questions from others. Not sure.
I will let you know.
Martin
Thanks
I did not see references from the claude ai.
Is there a way to tell it to list all references?
This is the link to the shared session
-- https://claude.ai/share/38e394c6-0275-44fe-a7e9-d4782758f0a1
I'm not sure what you mean by references. It shows what it's doing on-the-fly, but doesn't give a list of datasheets it read along the way.
If you're looking for the various code iterations, you get get to them by clicking on a box that looks like this:

So far, I've found you have to correct all of the main LLMs - Claude, ChatGPT, and Google Gemini - on basic syntax issues. This happens even with Excel Macros, which I thought there would be so many examples of that it would get them right with little trouble. Nope!
At this point the main LLMs have absorbed the basics of Spin - check this out:
ChatGPT link
I entered the chat to make some corrections -- hopefully, they stick. I ran out of tokens (using a free account ATM) so it switched, but I hope GPT-5 now has my guidelines in place.
-- https://chatgpt.com/share/68a1cdb2-9468-8006-ba04-cf451b7ca78d