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
  How-To: Remote Control Your Phone from Desktop via VNC biketool 2 422 10-12-2024, 11:47 AM
Last Post: biketool
  Office applications for the Pinephone Peter Gamma 2 519 09-05-2024, 09:22 AM
Last Post: Peter Gamma
  Struggle to install LibreOffice on the PinePhone Peter Gamma 50 35,022 07-26-2024, 10:35 PM
Last Post: Peter Gamma
  Why does Pine64 sabotage office on the Pinephone? Peter Gamma 5 969 07-04-2024, 07:34 AM
Last Post: Kevin Kofler
  Which word processor to choose for the Pinephone? Peter Gamma 16 5,233 06-22-2024, 07:28 AM
Last Post: Peter Gamma
  Samba share on the Pinephone? Peter Gamma 0 633 06-16-2024, 10:26 PM
Last Post: Peter Gamma
  Possible Free Backup Carrier for PinePhone PineFone 0 441 06-13-2024, 03:45 PM
Last Post: PineFone
  Using Signal on PinePhone in mid-2023? dante404 47 22,228 05-03-2024, 02:19 AM
Last Post: dragonhospital
  Slarm64 on PinePhone [Unofficial Slackware ARM - 64 bit] acid andy 38 32,664 04-23-2024, 10:29 AM
Last Post: donchurch
Wink PINEPHONE not booting Touchwood 2 1,201 02-23-2024, 07:27 AM
Last Post: Touchwood

Forum Jump:


Users browsing this thread: 1 Guest(s)