Article: NuttX RTOS for PinePhone: Feature Phone UI in LVGL, Zig and WebAssembly
#14
(06-21-2023, 03:18 AM)lupyuen Wrote: I hope this will get you started :-)

Indeed, a fun week was had Smile  I decided to start simple.  At first I was looking for the RGB LEDs (a green one triggers when the demo boots) but I couldnt find it, so maybe they are hardware controlled. 

Anyway I decided to try the VOL +/- buttons, since I wanted something very simple to see how the nuttx layer interacts with the Zig layer. The C include on the Zig side was a bit of a pain, until I remembered you mentioned somewhere only to include C stuff once, after that fix it was easier, although my include is deep into the nuttx layer, since I added the ADC logic under the src/a64 folder. 

Polling the ADC was defaulting to high value, not zero, maybe that is a pull-up? resister on the schematic (page 12).  And my microelectronics knowledge is poor and 30 years old hehe but it looks like the two resistors are designed to generate two different voltages for the ADC.  I tried to calculate the voltages there, 3V in, but ADC expecting 2V, and I think the signals work with the ADC default config of 1.7V, although then I was suspecting the pull-up acts in parallel...  as I said, very rusty old brain.  The KEYADC_DATA_REG (page 277 A64 user manual) produced some different values when I finally realised I needed to enable the CTRL register (KEYADC_EN).

I was expecting something like + at 1.64V and - at 1.8V, but with a 6 bit resolution, and assuming 2V spread, I see .35V and .16V, and assuming these pull down from 2V, that would give 1.65V and 1.84V, close enough... and either side of the configured 1.7V.  Phew, I am sure I am totally wrong with all that Smile but it works! ie value 5 for VOL+ and value 11 for VOL-, but since this is ADC I suspect I should be doing a +-2 range check... oh and I somehow expected both buttons together would generate a different value, but they dont.

Not quite the simple start I expected Smile but good fun.

I didn't try the IRQ approach so far... since that would mean calling from C to Zig, gulp!  My next challenge Smile

PS congrats on your article re RISC-V, it was no. 12 on HN when I spotted it Smile
  Reply


Messages In This Thread
RE: Article: NuttX RTOS for PinePhone: Feature Phone UI in LVGL, Zig and WebAssembly - by WhiteHexagon - 07-01-2023, 02:54 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Movuan distribution for PinePhone merom 4 744 04-07-2025, 12:32 AM
Last Post: tllim
  How-To: Remote Control Your Phone from Desktop via VNC biketool 6 1,828 03-05-2025, 06:18 AM
Last Post: Kevin Kofler
  Latest firmware for PinePhone modem! Subsentient 105 169,508 02-02-2025, 08:47 PM
Last Post: bacydentir85
  Slarm64 on PinePhone [Unofficial Slackware ARM - 64 bit] acid andy 40 41,070 12-28-2024, 12:19 AM
Last Post: mara
  Office applications for the Pinephone Peter Gamma 2 1,242 09-05-2024, 09:22 AM
Last Post: Peter Gamma
  Struggle to install LibreOffice on the PinePhone Peter Gamma 50 44,491 07-26-2024, 10:35 PM
Last Post: Peter Gamma
  Why does Pine64 sabotage office on the Pinephone? Peter Gamma 5 2,199 07-04-2024, 07:34 AM
Last Post: Kevin Kofler
  Which word processor to choose for the Pinephone? Peter Gamma 16 8,645 06-22-2024, 07:28 AM
Last Post: Peter Gamma
  Samba share on the Pinephone? Peter Gamma 0 1,025 06-16-2024, 10:26 PM
Last Post: Peter Gamma
  Possible Free Backup Carrier for PinePhone PineFone 0 962 06-13-2024, 03:45 PM
Last Post: PineFone

Forum Jump:


Users browsing this thread: 1 Guest(s)