Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 22:01 28 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : ArmmiteF4 firmware V5.07.00b1 - major upgrade

     Page 11 of 13    
Author Message
jaybek
Newbie

Joined: 25/05/2020
Location: Greenland
Posts: 18
Posted: 02:49am 14 May 2021
Copy link to clipboard 
Print this post

Hey All

I'm running  ArmmiteF4 Version 5.07.00b12, and this looks like a bug to me  


#MeTo ZX81
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1094
Posted: 05:40am 14 May 2021
Copy link to clipboard 
Print this post

What were you expecting to see?

In all three cases the INSTR function returns the position , starting from 1, of the first encountered instance of the search string, in you example, a space.

The third example has omitted the optional start position so defaults to 1 and again returns the first instance of the search string correctly.

Doug
Edited 2021-05-14 15:43 by panky
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1094
Posted: 06:10am 14 May 2021
Copy link to clipboard 
Print this post

The following code will print out all positions in the string to be searched of instances of the search string


dim ss$ = "This is a long line with multiple spaces ' string to be searched
dim s$ = " " ' this is the string to search for
ipos = 1 ' this is the position in string to be searched of search string

do while ipos <> 0
  ipos = INSTR(ipos,ss$,s$)
    if ipos = 0 then
      exit do
    endif
  print ipos,mid$(ss$,ipos,len(s$))
  ipos = ipos + 1
loop


Doug.
... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 06:52am 14 May 2021
Copy link to clipboard 
Print this post

  jaybek said  ... this looks like a bug to me...


don't think so. 3rd character, 5th character & 5th character - looks good to me.

throw some wood on the fire - what were you expecting to see?
Edited 2021-05-14 16:54 by CaptainBoing
 
jaybek
Newbie

Joined: 25/05/2020
Location: Greenland
Posts: 18
Posted: 09:59am 14 May 2021
Copy link to clipboard 
Print this post

Yes, You are right. Sorry, but I tried to run the little program from 'Getting Started...' by GG, page 44, and it keeps erroring out. I wrongfully assumed that it was Instr() there were cousin it to fail.

But something weird IS happening in the 'Function GetDays(d$)'.
If you, just before the 'If'-Statement, print out the value of 's1', and the your input data is in the correct format, you will get the value '3'.
And then the next line 'If s1 = 0 Then', -  evaluates True!  

I've bin coding in StarOffice Basic (Libre Office, Open Office) for more than a decade, and yes there are diffs, but this is a bit unexpected.  
#MeTo ZX81
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8583
Posted: 10:44am 14 May 2021
Copy link to clipboard 
Print this post

The program works fine - you must have a typo


' Example program to calculate the number of days between two dates

OPTION EXPLICIT
OPTION DEFAULT NONE
DIM STRING s
DIM FLOAT d1, d2
DO
 PRINT
 PRINT "Enter the date as  dd mmm yyyy"
 PRINT " First date":  INPUT s
 d1 = GetDays(s)
 IF d1 = 0 THEN PRINT "Invalid date!" : CONTINUE DO
 PRINT "Second date":  INPUT s
 d2 = GetDays(s)
 IF d2 = 0 THEN PRINT "Invalid date!" : CONTINUE DO
 PRINT "Difference is" ABS(d2 - d1) " days"
LOOP

' Calculate the number of days since 1/1/1900
 FUNCTION GetDays(d$) AS FLOAT
 LOCAL STRING Month(11) = ("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec")
 LOCAL FLOAT Days(11) = (0,31,59,90,120,151,181,212,243,273,304,334)
 LOCAL FLOAT day, mth, yr, s1, s2

 ' Find the separating space character within a date
 s1 = INSTR(d$, " ")
 IF s1 = 0 THEN EXIT FUNCTION
 s2 = INSTR(s1 + 1, d$, " ")
 IF s2 = 0 THEN EXIT FUNCTION

 ' Get the day, month and year as numbers
 day = VAL(MID$(d$, 1, s2 - 1)) - 1
 IF day < 0 OR day > 30 THEN EXIT FUNCTION
 FOR mth = 0 TO 11
   IF LCASE$(MID$(d$, s1 + 1, 3)) = Month(mth) THEN EXIT FOR
 NEXT mth
 IF mth > 11 THEN EXIT FUNCTION
 yr = VAL(MID$(d$, s2 + 1)) - 1900
 IF yr < 1 OR yr >= 200 THEN EXIT FUNCTION

 ' Calculate the number of days including adjustment for leap years
 GetDays = (yr * 365) + FIX((yr - 1) / 4)
 IF yr MOD 4 = 0 AND mth >= 2 THEN GetDays = GetDays + 1  GetDays = GetDays + Days(mth) + day
 END FUNCTION

Edited 2021-05-14 20:51 by matherp
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3659
Posted: 12:48pm 14 May 2021
Copy link to clipboard 
Print this post

Best thing is to reduce it to a tiny example and if the problem is still there, post the example.  Either someone will figure what's wrong or Geoff/Peter will have something useful to let them do a fix.

John
 
jaybek
Newbie

Joined: 25/05/2020
Location: Greenland
Posts: 18
Posted: 03:01pm 14 May 2021
Copy link to clipboard 
Print this post

Sorry, - but I'm obviously a narrow sighted idiot at times:

My glasses has bin missing for a couple of days, and in despair over that i couldn't get such a simple program to run, I yanked it into Libre office Basic, and made the few tweaks that was necessary to make it run, but i did get the exact same error there!!!
Then it was time for a strong cup of coffe and there they were! My glasses (I hate them! The Elves! I've bin looking there several times!! (Sometimes i love them)).
Running the program again (this time without a cane stick) i realized that the input format was 'dd mmm yyyy' and NOT 'dd mm yyyy' witch i'd bin using the hole time, not paying attention to why there was a StringArray of  month-names.

Wow, this is embarrassing. I discovered that I can still blush at my age of 60!

I really DO hope you all can have a good laugh over this, and i haven't caused too much disturbance. A typical 'Error 40'!

And if anyone cares, here is the Star Office Basic code:
OPTION EXPLICIT
'OPTION DEFAULT NONE (Not an OPTION here)

Sub Start
' Example program to calculate the number of days between two dates

DIM s AS STRING
DIM d1 AS DOUBLE, d2 AS Double

'DoThis: 'Works as well, but changed for a loop
DO
DO
'PRINT
'PRINT "Enter the date as dd mmm yyyy"
'PRINT "First date";
s = INPUTBOX("Enter the date as dd mmm yyyy", "First date")

d1 = GetDays(s)

IF d1 = 0 THEN PRINT "Invalid date!" ': GoTo DoThis 'CONTINUE DO.not existing
LOOP UNTIL d1 <> 0

DO
'PRINT "Second date";
s = INPUTBOX("Enter the date as dd mmm yyyy", "Second date")

d2 = GetDays(s)

IF d2 = 0 THEN PRINT "Invalid date!" ': GoTo DoThis
LOOP UNTIL d1 <> 0

PRINT "Difference is " & ABS(d2 -d1) & " days"

LOOP
End Sub

' Calculate the number of days since 1/1/1900
FUNCTION GetDays(d$) AS DOUBLE
Dim Month(11) AS STRING
Month() = Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec")
Dim Days(11) AS DOUBLE
Days() = Array(0,31,59,90,120,151,181,212,243,273,304,334)
Dim day, mth, yr, s1, s2 AS DOUBLE

' Find the separating space character within a date
s1 = INSTR(d$, " ")
'print s1, 3

IF s1 = 0 THEN EXIT FUNCTION

s2 = INSTR(s1 + 1, d$, " ")

IF s2 = 0 THEN EXIT FUNCTION

' Get the day, month and year as numbers
day = VAL(MID$(d$, 1, s2 -1)) -1

IF day < 0 OR day > 30 THEN EXIT FUNCTION

FOR mth = 0 TO 11
IF LCASE$(MID$(d$, s1 + 1, 3)) = Month(mth) THEN EXIT FOR
NEXT mth

IF mth > 11 THEN EXIT FUNCTION

yr = VAL(MID$(d$, s2 + 1)) -1900

IF yr < 1 OR yr >= 200 THEN EXIT FUNCTION

' Calculate the number of days including adjustment for leap years
GetDays =(yr * 365) + FIX((yr -1) / 4)

IF yr MOD 4 = 0 AND mth >= 2 THEN GetDays = GetDays + 1

GetDays = GetDays + Days(mth) + day
END FUNCTION

#MeTo ZX81
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1985
Posted: 07:21pm 14 May 2021
Copy link to clipboard 
Print this post

  jaybek said  

Wow, this is embarrassing. I discovered that I can still blush at my age of 60!


LOL, take a number.    
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 1785
Posted: 04:07am 15 May 2021
Copy link to clipboard 
Print this post

"LOL, take a number.    "
There are no numbers left! Over the past few years I've used all of them up.
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1082
Posted: 01:35am 21 May 2021
Copy link to clipboard 
Print this post

I decided to update my ArmmiteF4 to the latest version. Succeeded with no problems. (Well, my ST Link wouldn't enumerate in STM32Cube Programmer, but that doesn't really matter.)

While playing, I notice that the MATH ADD command is not implemented. Could it be added?
Visit Vegipete's *Mite Library for cool programs.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3015
Posted: 11:51am 21 May 2021
Copy link to clipboard 
Print this post

  vegipete said  I notice that the MATH ADD command is not implemented. Could it be added?


+1. If further alignment of F4/H7 MMBasic with CMM2 MMBasic is desirable, it would also be good to align the BLIT and SPRITE commands, in particular so that BLIT x1, y1, x2, y2, w, h on the F4 would work without the "w, h" (or with) (as it is on the CMM2 and as the F4 manual suggests it should). Translation for the F4 of SPRITE could be more inclusive.

Also, as a trivial matter, it would be convenient if RGB(ORANGE) and RGB(BROWN) worked on both the CMM2 and the F4.

Further, for the sake of translation from CMM2 to F4, it would be useful if "PRINT @" and "?@" were accepted, with the understanding that with "@", the target would be the LCD, not the PC console.

This would avoid this type of construction:

   if cpuType%=cmm2% then: ?@(60+sh/3,sv/2)"Bonus:"
   else: text 60+sh/3,sv/2,"Bonus:": endif

The recoding of ?@ to text has proven thus far to be very straightforward.

Aligning BLIT/SPRITE and "?@" would fix the majority of the issues I've had in trying to change vegipete's "Renewed Defense of the Green Hills" (Green Hills 2) to run on the F4 (aside from PAGE stuff, which must be handled case by case).

~
Edited 2021-05-21 21:52 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8583
Posted: 01:08pm 21 May 2021
Copy link to clipboard 
Print this post

The flash memory on the F4 is pretty much full so there is little scope for any enhancements
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3015
Posted: 01:58pm 21 May 2021
Copy link to clipboard 
Print this post

OK, thanks for considering.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1082
Posted: 04:13pm 21 May 2021
Copy link to clipboard 
Print this post

  lizby said  it would be useful if "PRINT @" and "?@" were accepted, with the understanding that with "@", the target would be the LCD, not the PC console.
That sounds like trouble. PRINT@ enables console output formatting.


   if cpuType%=cmm2% then: ?@(60+sh/3,sv/2)"Bonus:"
   else: text 60+sh/3,sv/2,"Bonus:": endif

I couldn't immediately tell you why I used ?@ instead of TEXT - maybe to save 2 characters? The CMM2 version should work fine with TEXT, and the ArmmiteF4 manual says PRINT@ should work as is too.
Visit Vegipete's *Mite Library for cool programs.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3015
Posted: 05:20pm 21 May 2021
Copy link to clipboard 
Print this post

  vegipete said  ... ArmmiteF4 manual says PRINT@ should work as is too.

But it doesn't--as far as I could tell. Since this was compressed code for the challenge, I assume you used ?@ to save characters.

On the CMM2 PRINT (and PRINT @) goes to both the PC console and the VGA output--on the F4, it only goes to the PC console. But PRINT @ on the F4 could be interpreted to go to the LCD only.

The point seems moot, though, if there is little or no space on the F4 for additions to the firmware.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1082
Posted: 05:32pm 21 May 2021
Copy link to clipboard 
Print this post

  lizby said  But it doesn't--as far as I could tell.

Ah, you're right. PRINT on the Armmite goes to the console only. On the CMM2, it goes to both the console AND the screen. I'd say change all PRINT commands in my Green Hills program to TEXT - no need for the IF cpu.type.
Visit Vegipete's *Mite Library for cool programs.
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5729
Posted: 09:51pm 21 May 2021
Copy link to clipboard 
Print this post

The F4 seems to have more in common with the Micromite+ than it has with the Maximite machines.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3015
Posted: 10:44pm 21 May 2021
Copy link to clipboard 
Print this post

  Mixtel90 said  The F4 seems to have more in common with the Micromite+ than it has with the Maximite machines.

Absolutely. It doesn't have VGA output and would typically run a program with an LCD attached for interaction. It doesn't have advanced graphics of the sort the CMM2 has, but can run certain games, and has a lot of pins available for I/O--in an all-in-one, no fuss module to which a small and inexpensive LCD can easily be attached, and larger ones up to 9 inches with adaptor(s).
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 844
Posted: 04:00am 22 May 2021
Copy link to clipboard 
Print this post

The manual is updated to Draft3 and should match the software up to Beta12

Link to Armmite F4 Manual thread

Regards
Gerry
Edited 2021-05-22 14:32 by disco4now
Latest F4 Latest H7
 
     Page 11 of 13    
Print this page
© JAQ Software 2024