Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 21:40 17 May 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 : Micromite Firmware Update V5.04.05

     Page 1 of 2    
Author Message
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3167
Posted: 09:08pm 30 Jun 2017
Copy link to clipboard 
Print this post

There is an updated version of the Micromite firmware which can be downloaded from http://geoffg.net/micromite.html (scroll to the bottom of the page).

This is a minor upgrade and is released to fix annoying bugs in the LEFT$() function and the ERASE command. More details are in the Change Log which is included in the firmware download. There has been no significantly new functionality so the manuals have had only minor updates.

Geoff
Geoff Graham - http://geoffg.net
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 09:17pm 30 Jun 2017
Copy link to clipboard 
Print this post

Thanks for the I2C mod Geoff.
If the weather warnings last night were right, you could be testing a lightning sensor now!

Jim
VK7JH
MMedit   MMBasic Help
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3167
Posted: 09:55pm 30 Jun 2017
Copy link to clipboard 
Print this post

Yes, the sky is what can only be described as "threateningly black". If I had a dog it would be climbing the walls right now.
Geoff Graham - http://geoffg.net
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 06:57am 05 Jul 2017
Copy link to clipboard 
Print this post

Geoff
Am I right in thinking there is still no FIELD$() function for the MM? only for the extreme?
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3167
Posted: 12:19pm 05 Jul 2017
Copy link to clipboard 
Print this post

No, because it is so easy to implement in BASIC I will not include it in MMBasic. The language does not need to be cluttered with functions that can be encapsulated in a simple subroutine.

Geoff
Geoff Graham - http://geoffg.net
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1664
Posted: 01:08pm 05 Jul 2017
Copy link to clipboard 
Print this post

  Geoffg said   No, because it is so easy to implement in BASIC I will not include it in MMBasic. The language does not need to be cluttered with functions that can be encapsulated in a simple subroutine.

Geoff


The only catch with these Simple Subroutines is either knowing they exist, and being able to find them.

Maybe this could be addressed by Glenn creating a Sticky Post that can contain those code snippets.

That would be a great asset to new comers visiting the site.

There is the MMbasic Library Pinned thread, but it's well out of date.

If Glenn's able to do this, with either 1 or 2 threads, I'm sure others would volunteer to administer that thread & move of delete posts as appropriate.


Cheers

Phil.

 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1421
Posted: 01:24pm 05 Jul 2017
Copy link to clipboard 
Print this post

I've offered before and I'll offer again that the CG site can be used for library routines.

The site is behind on updating. I would need help from some "librarians" to capture and annotate various library functions.




Micromites and Maximites! - Beginning Maximite
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 1994
Posted: 06:35pm 05 Jul 2017
Copy link to clipboard 
Print this post

  Phil23 said  
The only catch with these Simple Subroutines is either knowing they exist, and being able to find them.
<snip>
There is the MMbasic Library Pinned thread, but it's well out of date.


This was discussed in a post a while back.

There are two options detailed there. One I believe better than the other (for various reasons )

As Geoff said at the time when I set up the wiki, the problem is keeping the impetus - people forget to publish what they do. Several regular members of TBS have joined the wiki (membership makes it possible to contribute and critique articles - reading is open to all) there is lots of stuff that gets posted here that should be kept for posterity but isn't and forums are not meant to be code libraries.

"
* Dedicated to doing one task well.
* No single "keeper" - Everyone can add articles at any time.
* Everyone can police/correct/modify articles at any time.
* Rich articles with pix & graphics to support the thinking behind.
* Focused discussion.
* Article history with roll-back.
* Searchable within the wiki.
* Searchable on the web.
"

At the time I set up the wiki, neither Geoff nor Hugh (the original keepers of the library) had the time or resources to maintain it and having a single person look after it with snippets "sent" in, as it was is frankly archaic - we can all contribute AND share the load - we all should.

This wiki is a free, non-commercial, ad-free, up-to-date as we make it (community driven) method of making sure great stuff stays with the community and stays visible.

hEdited by CaptainBoing 2017-07-07
 
piclover
Senior Member

Joined: 14/06/2015
Location: France
Posts: 134
Posted: 01:28pm 20 Jul 2017
Copy link to clipboard 
Print this post

@ Geoff

I think I found a bug in ACOS: targ is not set there...

I also would like to see the two following changes adopted:

- Addition of a MM.SPIOPEN flag (super-useful with touch screen that got the touch event processed in an interrupt, while other SPI devices might have opened the SPI port already and thus a SPI transaction in progress). It is super-easy, since the corresponding flag already exists in the firmware. It also costs almost nothing, firmware size wise.

- Not resetting the pullup/pulldown status of digital pins when switching form a DIN to a FIN, CIN or PIN mode, which allows getting an easy way (i.e. without having to use a CFunction neither to extend the MMBASIC syntax for SETPIN) to get a pullup or pulldown resistor for the latter modes, by using two consecutive SETPIN commands, the first with DIN and the pull up/down status set, e.g. SETPIN 16,DIN,PULLUP;SETPIN 16,FIN

The following patch implements all of the above.

diff -durN --strip-trailing-cr Micromite-5.4.5/General/External.c Micromite-5.4.5-patched/General/External.c
--- Micromite-5.4.5/General/External.c 2017-06-12 05:08:35.000000000 +0200
+++ Micromite-5.4.5-patched/General/External.c 2017-07-02 11:00:44.671507112 +0200
@@ -918,8 +918,10 @@
if(pin == INT3PIN) ConfigINT3(EXT_INT_PRI_2 | RISING_EDGE_INT | EXT_INT_DISABLE);
if(pin == INT4PIN && IrState == IR_CLOSED) ConfigINT4(EXT_INT_PRI_2 | RISING_EDGE_INT | EXT_INT_DISABLE);

- // make sure any pullups/pulldowns are removed in case we are changing from a digital input
- PinSetBit(pin, CNPUCLR); PinSetBit(pin, CNPDCLR);
+ if (cfg != EXT_FREQ_IN && cfg != EXT_PER_IN && cfg != EXT_CNT_IN) {
+ // make sure any pullups/pulldowns are removed in case we are changing from a digital input
+ PinSetBit(pin, CNPUCLR); PinSetBit(pin, CNPDCLR);
+ }

for(i = 0; i < NBRINTERRUPTS; i++)
if(inttbl.pin == pin)
diff -durN --strip-trailing-cr Micromite-5.4.5/General/MM_Custom.c Micromite-5.4.5-patched/General/MM_Custom.c
--- Micromite-5.4.5/General/MM_Custom.c 2017-03-10 12:30:30.000000000 +0100
+++ Micromite-5.4.5-patched/General/MM_Custom.c 2017-07-02 11:00:44.698173779 +0200
@@ -14,7 +14,7 @@

#include "../MMBasic_Includes.h"
#include "../Hardware_Includes.h"
-
+#include "SPI.h"

/*********************************************************************************************************************** **
************************************************************************************************************************ **
@@ -52,3 +52,7 @@

************************************************************************************************************************ ********************/

+void fun_spiopen(void) {
+ iret = SPIOpen;
+ targ = T_INT;
+}
diff -durN --strip-trailing-cr Micromite-5.4.5/General/MM_Custom.h Micromite-5.4.5-patched/General/MM_Custom.h
--- Micromite-5.4.5/General/MM_Custom.h 2017-05-13 03:12:52.000000000 +0200
+++ Micromite-5.4.5-patched/General/MM_Custom.h 2017-07-02 11:00:44.698173779 +0200
@@ -29,6 +29,8 @@
// void fun_???(void)
// void op_???(void)

+void fun_spiopen(void);
+
#endif


@@ -55,5 +57,7 @@
// where type is T_NA, T_FUN, T_FNA or T_OPER augmented by the types T_STR and/or T_NBR
// and P is the precedence (which is only used for operators)

+ { "MM.SPIOPEN", T_FNA | T_INT, 0, fun_spiopen },
+
#endif

diff -durN --strip-trailing-cr Micromite-5.4.5/MMBasic/Functions.c Micromite-5.4.5-patched/MMBasic/Functions.c
--- Micromite-5.4.5/MMBasic/Functions.c 2017-06-14 09:32:40.000000000 +0200
+++ Micromite-5.4.5-patched/MMBasic/Functions.c 2017-07-21 01:04:28.364454616 +0200
@@ -702,6 +702,7 @@
} else {
fret = 1.5707963268 - arcsinus(f);
}
+ targ = T_NBR;
}



Edited by piclover 2017-07-21
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 11:23pm 15 Aug 2017
Copy link to clipboard 
Print this post

I've just upgraded my E100 board to V5.04.05 but I'm getting an error when I try and configure the display
[quote]
OPTION LCDPANEL SSD1963_7, LANDSCAPE, 53
Error: Pin 18 is reserved on startup
>[/quote]

Anyone got any ideas why or how to overcome this?

This is my complete config parameters

OPTION AUTORUN ON
OPTION LCDPANEL SSD1963_7, LANDSCAPE, 53
OPTION TOUCH 50, 51
OPTION SDCARD 52
Edited by lew247 2017-08-17
 
disco4now

Guru

Joined: 18/12/2014
Location: Australia
Posts: 844
Posted: 02:29am 16 Aug 2017
Copy link to clipboard 
Print this post

Hi Lewis,
Make sure you don't have any code like this in mm.startup


sub mm.startup
' setrd(6)' set up the read pin
end sub

A CPU RESTART may be required if mm.startup has added anything.

Do an
OPTION LCDPANEL DISABLE
use the following to re-enable LCD with the RD pin enabled
OPTION LCDPANEL SSD1963_7,L,,6 'With RD pin for 5.03 onwards

I think the options you suggest is not what is required on the E100.
Below is what I am using I think.


' Commands for setting up the E100 board
'OPTION SDCARD 47
'OPTION LCDPANEL SSD1963_7,L,,6 'With RD pin for 5.03 onwards
'OPTION TOUCH 01,40
'OPTION TOUCH 01,40,39 'with piezo
Latest F4 Latest H7
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 11:53am 16 Aug 2017
Copy link to clipboard 
Print this post

Thanks Gerry, I'll give that a try in the morning, I'll reflash the MM first then try it
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1141
Posted: 06:48am 29 Aug 2017
Copy link to clipboard 
Print this post

Hi Geoff,

I fear there is a bug in the way the MMBasic 5.04.05 handles "passed string arrays". There are no issues with MMBasic V5.0. The problem only affects strings (AFAIK).

Enclosed you will find some demos. I hope they are helpful!
2017-08-29_190600_Bug_Report_passed_arrays.zip (edited!)

Maybe this issue is somehow connected with the (very valuable) "Typed Parameters" for CFunctions?

I hope you can fix that easily.

Best regards
Michael

Edit:
System: MX170/28


PS:
I wanted to send this as pm, but it seems that I can not send zip attachments.
Maybe something that an admin can change?
Edited by twofingers 2017-08-30
 
flip
Senior Member

Joined: 18/07/2016
Location: Australia
Posts: 114
Posted: 04:51pm 29 Aug 2017
Copy link to clipboard 
Print this post

Hi twofingers,

I tried your QuickSort - Passed Arrays BUG DEMO2.txt
with MMBasic for DOS,and it failed as per output below.(last output for n was 1000 as per first line in below - just before crash)

1000 2027.952927
[54] t=arr(leftNIdx):arr(leftNIdx)=arr(rightNIdx):arr(rightNIdx)=t
Error: String too long
> trace list 50
[55][56][57][58][59][60][64][65][41][42][43][44][45][68][66][41][42][43][44][45][68][67][68][67][68][67][68][67][68][67][68][67][68][67][68][67][68][66][41][42][43][44][45][46][47][48][50][51][53][54]

Interesting bit is the TRACE LIST..the code seems to repeat lines 68 & 67 NINE times !? I would expect that with recursion, but I know MMBasic doesn't support recursion.
Lines [EDIT inserted 66] 67 & 68 (note order of these) are as follows:
quicksort arr(), pivot + 1, rightN
End If
End Sub


EVEN MORE interestingly,...typing CLEAR (or not) and re-running the program (it still fails at exactly the same point!) but it generates a different TRACE LIST result:(Edited 4:15UTC)
[22][23][21][22][23][21][22][23][21][22][23][21][22][23][21][22][23][21][22][23][21][22][23][21][22][23][21][22][23][21][22][23][24][25][26][41][42][43][44][45][46][47][48][49][50][49][50][51][53][54]


Hope this helps either you or Geoff diagnose the problem further!

EDIT: answered your problem: ....you are attempting to use recursion which I believe is not supported by MMBASIC

Geoff might confirm this.

Regards,
Phil
Edited by flip 2017-08-31
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5923
Posted: 07:31pm 29 Aug 2017
Copy link to clipboard 
Print this post

  flip said  
EDIT: answered your problem: ....you are attempting to use recursion which I believe is not supported by MMBASIC

I am not sure how deep you can go but recursion is certainly doable.

A bit early for a Christmas tree but here it is anyway.
(runs on a 240x320 display)
  Quote  'Title: Fractal Tree
newX=160 'Tree starting point
newY=220
angle = -
30
delta =
10
leng =
60
dir =
270
TurtleSpeed =
75 'speed options
RAD=6.283185/360 'degrees to radians
DIM stack(100) 'FILO stack
DIM AS INTEGER cols(2)
cols(
0)= RGB(RED)
cols(
1)= RGB(WHITE)
stackpos=
1
c=
0
CLS
again:
newX=
160
newY=
220
leng =
60
dir =
270

c=
1-c
LINE newX, newY-1, newX, newY ,1,cols(c)
loopcount =
0
drawtree

PRINT "Subroutine called ";loopcount;" times."
GOTO again
END

SUB drawtree
loopcount = loopcount +
1
IF (leng > 0) THEN
oldX=newX
oldY=newY
newX=oldX -
COS(dir*RAD)*leng
newY=oldY +
SIN(dir*RAD)*leng
LINE oldX, oldY, newX, newY,1,cols(c)
PAUSE TurtleSpeed
dir=dir+angle
stack(stackpos)=leng
stackpos=stackpos+
1
leng = leng - delta
drawtree
'recursive calling itself
dir=dir-(angle * 2)
drawtree
'recursive calling itself
dir=dir+angle
stackpos=stackpos-
1
leng = stack(stackpos)
oldX=newX
oldY=newY
newX=oldX -
COS(dir*RAD+3.14159)*leng
newY=oldY +
SIN(dir*RAD+3.14159)*leng
LINE oldX, oldY, newX, newY,1,cols(c)
PAUSE TurtleSpeed
ENDIF
END SUB


Jim
VK7JH
MMedit   MMBasic Help
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1141
Posted: 09:43pm 29 Aug 2017
Copy link to clipboard 
Print this post

Thanks Phil and Jim!

@Phil

In this case the recursion can't be the problem. All the code in the zip runs perfectly with MMBasic V5.0.0 (MX170/28).

It runs also without issues if the string array is globally.
But this is not very elegant or flexible:

' Working(!) DEMO for the "Passed Arrays" bug
' String array [q()] is globally
'------------------------------------------------------------------------
'Quicksort for strings using recursion
's. https://rosettacode.org/wiki/Sorting_algorithms/Quicksort
'

Option base 0
Dim integer max = 1000
Dim string q(max) length 20, qo

For n = 0 To max
q(n)=Str$(Rnd()*10000,6)
Print n,q(n)
Next

Timer= 0
Quicksort 0, max
tx= Timer/1000

qo=""
For n = 0 To max
Print "#"n,q(n)
If q(n)<qo Then Print" error":End
qo=q(n)
Next
Print
Print tx "sec"
End

' Quicksort
Sub quicksort (leftN As INTEGER, rightN As integer)
Local pivot As integer, leftNIdx As INTEGER, rightNIdx As INTEGER
Local t As string
leftNIdx = leftN
rightNIdx = rightN
If (rightN - leftN) > 0 Then
pivot = (leftN + rightN) / 2
Do While (leftNIdx <= pivot) And (rightNIdx >= pivot)
Do While (q(leftNIdx) < q(pivot)) And (leftNIdx <= pivot)
leftNIdx = leftNIdx + 1
Loop
Do While (q(rightNIdx) > q(pivot)) And (rightNIdx >= pivot)
rightNIdx = rightNIdx - 1
Loop
t=q(leftNIdx):q(leftNIdx)=q(rightNIdx):q(rightNIdx)=t
leftNIdx = leftNIdx + 1
rightNIdx = rightNIdx - 1
If (leftNIdx - 1) = pivot Then
rightNIdx = rightNIdx + 1
pivot = rightNIdx
ElseIf (rightNIdx + 1) = pivot Then
leftNIdx = leftNIdx - 1
pivot = leftNIdx
End If
Loop
quicksort leftN, pivot - 1
quicksort pivot + 1, rightN
End If
End Sub


Interestingly, the code (Not the code above!) behaves differently depending on whether I run it from the edit window or command line. Very strange.

Regards
MichaelEdited by twofingers 2017-08-31
 
flip
Senior Member

Joined: 18/07/2016
Location: Australia
Posts: 114
Posted: 10:59pm 29 Aug 2017
Copy link to clipboard 
Print this post

Well there you go. Something stuck in my head from early Maximite days about recursion not being available. Indeed it is in the manual. Thanks Michael & Jim for that
  Quote  The argument can also be another defined function or the same function if recursion is to be used (the recursion stack is limited to 1000 nested calls)

So out of curiosity I pushed the limits:
Dim MaxDepth%=0
Function Recurse(a$) As String
Depth%=Depth%+1: If Depth%>MaxDepth% Then MaxDepth%=Depth%
If Len(a$)=1 Then
Recurse=a$
Else
Recurse=Recurse(Mid$(a$,2))
EndIf
End Function

Dim a$
For i%=32 to 114
a$=a$+Chr$(i%)
Depth%=0
? Recurse(a$);
Next i%
?
? "Max recursions tried:";MaxDepth%;", now trying 84..fails"

For i%=32 to 115
a$=a$+Chr$(i%)
Depth%=0
? Recurse(a$);
Next i%

And I got 83 iterations only
DOS MMBasic Ver 5.04.05 Beta 7
Copyright 2011-2017 Geoff Graham

!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqr
Max recursions tried: 83, now trying 84..fails
[46] Recurse=Recurse(Mid$(a$,2))
Error: Not enough memory
>


Of course the stack usage could be consumed more by my program passing a String...

So perhaps there are 3 symptoms of one problem?
1...Your original bug in 5.04.05 which I confirm in DOS version of same
2...I also confirm that with Michael's code behaves differently on subsequent runs
3...Stack Space can be used which reduces the 1000 iteration capacity

[EDIT] Also tried Michael's test (running from EDIT window) with my code, but it still crashed at 84 iterations.[/EDIT]

Hope it helps and just doesn't cause Geoff a wild goose chase!

Regards,
Phil
Edited by flip 2017-08-31
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1141
Posted: 11:25pm 29 Aug 2017
Copy link to clipboard 
Print this post

@Phil

Thanks! Sometimes 5 eyes can see more than just 2!
But please keep in mind that the Comb Sort examples don't use recursion.
It took me days to catch this bug because sometimes he does not show up.

If I can do something to clearify this issue, please let me know.

Michael
 
flip
Senior Member

Joined: 18/07/2016
Location: Australia
Posts: 114
Posted: 11:43pm 29 Aug 2017
Copy link to clipboard 
Print this post

Hi all,
[Threadjack]
As a matter of forum etiquette,

1. Am I doing the right thing in regards to piggybacking and testing and commenting? I can get over-excited sometimes and may need to tone down. I can get off-track but like to help get to the bottom of things.

2 Bug reports. Would Geoff / anyone be happier taking bug reports, discussions thereof or other off-line?

...reason being is that this is the first chat forum I've ever been involved with, I greatly enjoy all the contributions to this forum and contributors all are similarly interested as me - which is why I joined, and why I ask.

MM is the most fun I've had over and above any programming language / Basic dialect.

Happy to take any PM on this from anyone if preferred.

[/Threadjack]
[EDIT] Just saw your post Michael - will do some more thinking and testing [/EDIT])
Regards,
PhilEdited by flip 2017-08-31
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1141
Posted: 12:27am 30 Aug 2017
Copy link to clipboard 
Print this post

Hi Phil,

Just my opinion:

@1: AFAIK you are doing nothing wrong, don't worry!

@2: This can only Geoff answer, but AFAIK Geoff is very tough regarding bug reports. I confirm this can be a sensitive subject. In his code is so much work (life time and heart blood).

But generally: I think it's always wise to think twice before the (two)fingers touch the keyboard.

Michael
 
     Page 1 of 2    
Print this page
© JAQ Software 2024