Can the battery charge level be read or estimated from MMBASIC?
supposedly you can get the percentage via i2c of the keyboard in register REG_ID_BAT = 0x0b
Direct get bat info from PicoMIte(MMBasic), no
but I add the sample code in
basicly just like @pkr said
send i2c command 0x0b to the keyboard and get return data
Then I found out there is a bug in current keyboard firmware
if we send i2c command 0x0b to the kbd ,there is a high odds that will crash keyboard
And I fixed this bug
so If you are really interesting in this ,here is the docs for How to flash the new firmware into keyboard of picocalc
important note is if we want the correct battery percent
we need to insert batteries first without any cable
then Power ON PIcoCalc
then we can plug typec cable , get battery info from serial port or else.
There is also a shortcut on keyboard to get battery level
on keyboard press Alt+B
the top-left led will blink
- 3 times means full,or above 80%
- 2 times means 50%
- 1 means low
However, due to the low power consumption of the picocalc ,even 1 blink will last enough time
what a legend!
oh please. I am sorry but no need to be sarcastic
I’m managing all these codes alone, so occasional bugs are inevitable
I literally mean you are a legend for what you are doing, only love and appreciation.
Oh I see,thanks
This may be a misunderstanding caused by language barriers. no big deal
And I’m definitely not deserve “legend” word, overly praised
just a careless man, hopeful got your understanding when we met bugs
Dare we ask for a new build for Pico2 with latest MMBasic and the keyboard fix all in one ?. Your last build is downloaded and Pico2 sat here waiting for my PicoCalc to arrive in a few weeks max (hopefully)…
keyboard is separate independent thing/device (not related nor to pico 1/2, nor to basic), you can update it any time
Is it not possible using the i2c commands in PicoMite? Details are in Appendix B of the manual. I’m not sure how those commands might be used to configure it. But it looks like it might be possible, if the correct pin(s) were specified, the speed was set, etc.
The keyboard shortcut that blinks the LED is useful.
Have you also fixed the bug where the PicoCalc’s I2C will stop responding?
When I2C stop responding?
I am a little confused
Many people here have been getting a condition where the I2C bus stops responding. Haven’t you had that problem? In any case, I changed the source code so that SLOW sets the speed to 10kHz instead of 100kHz and it’s been over six hours with no lockup. The computer does run a little slower for graphics-heavy programs, though since the LCD is also on the I2C bus.
“since the LCD is also on the I2C bus.” Are you sure about that?
Thank you! You found the keyboard disconnect bug that’s been around so long. I just checked and while guu’s code has 10000
, mine had 100000
in mmc_stm32.c
where the SLOW
option is being handled. I somehow missed that when I updated to newer RCs of PicoMite.
I’m doing a test build now and once I check that I’ll push it up to git and put a new set of release files for download. I’ve also got changes to fix the key assignments you highlighted in the other thread. I had already fixed DEL as you had mentioned, but I’ve also added fixes for ALT, and the SHIFT modified ones you pointed out.
EDIT:
An updated release is available here, with the i2c timing fix and the keyboard mapping fixes.
To me, it looks like the LCD is an ILI9488 which has an SPI interface but is controlled by the STM32 chip which, in turn, is on the I2C bus. I’m no hardware expert, though, so if you are, I’ll defer to your knowledge. In any case, the classic graphics program that draws a hat used to run in 14.33 seconds now runs at over 17 seconds.
10 TIMER =0
20 P=160: Q=100
30 XP=144: XR=1.5*3.1415927
40 YP=56: YR=1: ZP=64
50 XF=XR/XP: YF=YP/YR: ZF=XR/ZP
60 FOR ZI=-Q TO Q-1
70 IF ZI<-ZP OR ZI>ZP GOTO 150
80 ZT=ZI*XP/ZP: ZZ=ZI
90 XL=INT(.5+SQR(XP*XP-ZT*ZT))
100 FOR XI=-XL TO XL
110 XT=SQR(XI*XI+ZT*ZT)*XF: XX=XI
120 YY=(SIN(XT)+.4*SIN(3*XT))*YF
130 GOSUB 170
140 NEXT XI
150 NEXT ZI
160 T=TIMER/1000: DO: LOOP UNTIL INKEY$<>"": PRINT "TIME:";T;" SECONDS": END
170 X1=XX+ZZ+P
180 Y1=320-(YY-ZZ+Q)
190 PIXEL X1,Y1,RGB(white)
200 IF Y1=320 GOTO 220
210 LINE X1,Y1-1,X1,0,,0
220 RETURN
The LCD is on the SPI bus!
The SPI bus is controlled directly by the Pico. However, the speed decrease you’re seeing may be due to keyboard polling being slower?
That’s a distinct possibility. BTW, have you tried the hat.bas program I posted?
There’s a notable difference in speed when overclocking with OPTION CPUSPEED as well. If flash was wiped with a firmware update that option would have been reset. But if you were running that program with the same CPUSPEED both times then I guess it was the keyboard change that affected it.