Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 16:19 23 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 : CMM2: V5.07.01b1

     Page 1 of 2    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8572
Posted: 11:30am 25 Jul 2021
Copy link to clipboard 
Print this post

Please download and test V5.07.01b1

http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip

Changes from V5.07.00

Full implementation of the GUI controls as per MM+ but using the mouse as the I/F (except GUI BEEP).
NB: the TOUCH function is renamed CLICK.
The mouse must be connected and working for the GUI commands to work and have been set up using the OPTION MOUSE command
Space for the controls must be provided using the OPTION MAXCTRLS n command

New math command
MATH INVERSE array!(), inversearray!()


This returns the inverse of array!() in inversearray!(). The array must be square and you will get an error if the array cannot be inverted (determinant=0)

New math function
MATH(DETERMINANT array!())

returns the determinant of the array. The array must be square

Enhancement of the RESTORE comand
The restore command can now take a variable as the parameter. A numerical variable should be used for a line number and a string variable for a label

Enhancement of the READ command
The read command can now take arrays as one or more of the parameters. As usual arrays are specified with an empty set of brackets.

e.g READ a,b c(), s$(), t$
This will read numbers into a and b, it will then fill the array c() with numbers (NB: if C is multidimensional then the leftmost dimension will be the fastest moving). It will then fill the array s$() with strings and then finally load the string t$. In all cases the firmwware uses the size of an array to determine how many elements are to be read.

New GUI CURSOR commands

GUI CURSOR LINK MOUSE
GUI CURSOUR UNLINK MOUSE


These commands link and unlink mouse activity to the cursor. When linked the cursor will automatically track the mouse activity. The mouse must be opened using the CONTROLLER MOUSE OPEN command before the cursor is linked.

Bug fixes:
Fixed lockup if the MODE command is used without parameters - now gives an error
Fixes bugs in VAR and MEMORY commands when the saved variable area is corrupted for any reason. Improves reliability of VAR SAVE
Fixes bug in CAT command when the two strings would exceed 255 characters
Adds lightgrey as a valid colour as well as lightgray

MOUSE LINK demo program
gui cursor on
controller mouse open 0
gui cursor link mouse
do:loop


GUI demo program
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Demonstration program for the CMM2
' It does not do anything useful except demo the various controls
'
' Geoff Graham, October 2015
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
Dim ledsY
mode 10
option console serial
Colour RGB(white), RGB(black)
' reference numbers for the controls are defined as constants
Const c_head = 1, c_pmp = 2, sw_pmp = 3, c_flow = 4, tb_flow = 5
Const led_run = 6, led_alarm = 7
Const frm_alarm = 20, nbr_hi = 21, nbr_lo = 22, pb_test =23
Const c_hi = 24, c_lo = 25
Const frm_pump = 30, r_econ = 31, r_norm = 32, r_hi = 33
Const frm_log = 40, cb_enabled = 41, c_fname = 42, tb_fname = 43
Const c_log = 44, cb_flow = 45, cb_pwr = 46, cb_warn = 47
Const cb_alarm = 48, c_bright = 49, sb_bright = 50
' now draw the "Pump Control" display
'CLS
dim integer x, y, lb, rb, sb, xs, ys, cs, ss
'sprite load "mouse.spr",1
gui cursor on 0, mm.hres\2,mm.vres\2
GUI Interrupt TouchDown, TouchUp
' display the heading
Font 2,2 : GUI Caption c_head, "Pump Control", 10, 0
Font 3 : GUI Caption c_pmp, "Pump", 20, 60, , RGB(brown)
' now, define and display the controls
' first
GUI Switch sw_pmp, "ON|OFF", 20, 90, 150, 50, RGB(white),RGB(brown)
CtrlVal(sw_pmp) = 1
' the flow rate display box
Font 3 : GUI Caption c_flow, "Flow Rate", 20, 170,, RGB(brown),0
Font 4 : GUI Displaybox tb_flow, 20, 200, 150, 45
CtrlVal(tb_flow) = "20.1"
' the radio buttons and their frame
Font 3 : GUI Frame frm_pump, "Power", 20, 290, 170, 163,RGB(200,20,255)
GUI Radio r_econ, "Economy", 40, 318, 15, RGB(230, 230, 255)
GUI Radio r_norm, "Normal", 40, 364
GUI Radio r_hi, "High", 40, 408
CtrlVal(r_norm) = 1 ' start with the "normal" button selected
' the alarm frame with two number boxes and a push button switch
Font 3 : GUI Frame frm_alarm, "Alarm", 220, 220, 200, 233,RGB(green)
GUI Caption c_hi, "High:", 232, 260, LT, RGB(yellow)
GUI Numberbox nbr_hi, 318,MM.info(VPos)-6,90,MM.info(FontHeight)+12,RGB(yellow),RGB(64,64,64)
GUI Caption c_lo, "Low:", 232, 325, LT, RGB(yellow),0
GUI Numberbox nbr_lo, 318,MM.info(VPos)-6,90,MM.info(FontHeight)+12,RGB(yellow),RGB(64,64,64)
GUI Button pb_test, "TEST", 257, 383, 130, 40,RGB(yellow), RGB(red)
CtrlVal(nbr_lo) = 15.7 : CtrlVal(nbr_hi) = 35.5
' draw the two LEDs
Const ledsX = 240, coff = 50 ' define their position
ledsY = 90 : GUI LED led_run, "Running", ledsX, ledsY, 15, RGB(green)
ledsY = ledsY+49 : GUI LED led_alarm, "Alarm", ledsX, ledsY, 15, RGB(red)
CtrlVal(led_run) = 1 ' the switch defaults to on so set the LED on
' the logging frame with check boxes and a text box
Colour RGB(cyan), 0
GUI Frame frm_log, "Log File", 450, 20, 330, 355, RGB(green)
GUI Checkbox cb_enabled, "Logging Enabled", 470, 50, 30, RGB(cyan)
GUI Caption c_fname, "File Name", 470, 105
GUI Textbox tb_fname, 470, 135, 290, 40, RGB(cyan), RGB(64,64,64)
GUI Caption c_log, "Record:", 470, 205, , RGB(cyan), 0
GUI Checkbox cb_flow, "Flow Rate", 500, 245, 25
GUI Checkbox cb_alarm, "Alarms", 500, 285, 25
GUI Checkbox cb_warn, "Warnings", 500, 325, 25
CtrlVal(cb_enabled) = 1
CtrlVal(tb_fname) = "LOGFILE.TXT"
' define and display the spinbox for controlling the backlight
GUI Caption c_bright, "Backlight", 442, 415,,RGB(200,200,255),0
GUI Spinbox sb_bright, MM.info(HPos) + 8, 400, 200, 50,,,10, 10, 100
CtrlVal(sb_bright) = 50
' All the controls have been defined and displayed. At this point
' the program could do some real work but because this is just a
' demo there is nothing to do. So it just sits in a loop.
Do
Loop
' the interrupt routine for touch down
' using a select case command it has a different process for each
' control
Sub TouchDown
 local integer mbox
'  print "down"
 Select Case click(REF) ' find out the control touched
 Case cb_enabled ' the enable check box
   If CtrlVal(cb_enabled) Then
     GUI Restore c_fname, tb_fname, c_log, cb_flow, cb_alarm, cb_warn
   Else
     mbox=MsgBox("Are you sure?", "YES","CANCEL")
'      print mbox
     if mbox=1 then
       GUI Disable c_fname, tb_fname, c_log, cb_flow, cb_alarm, cb_warn
     else
       CtrlVal(cb_enabled)=1
     endif
   EndIf
 Case sb_bright ' the brightness spin box
'    BackLight CtrlVal(sb_bright)
 Case sw_pmp ' the pump on/off switch
   CtrlVal(led_run) = CtrlVal(sw_pmp)
   CtrlVal(tb_flow) = Str$(CtrlVal(sw_pmp) * 20.1)
   CtrlVal(r_norm) = 1
 Case pb_test ' the alarm test button
   CtrlVal(led_alarm) = 1
'    GUI beep 250
 Case r_econ ' the economy radio button
   CtrlVal(tb_flow) = Str$(CtrlVal(sw_pmp) * 18.3)
 Case r_norm ' the normal radio button
   CtrlVal(tb_flow) = Str$(CtrlVal(sw_pmp) * 20.1)
 Case r_hi ' the high radio button
   CtrlVal(tb_flow) = Str$(CtrlVal(sw_pmp) * 23.7)
 End Select
End Sub
' interrupt routine when the touch is removed
Sub TouchUp
 Select Case click(LASTREF) ' use the last reference
 Case pb_test ' was it the test button
   CtrlVal(led_alarm) = 0 ' turn off the LED
 End Select
End Sub
'
function MM.CURSOR( t as integer) as integer
 static float lasttime
 if timer> lasttime+20 or timer<lasttime then
   x=mouse(x,1)
   y=mouse(y,1)
   lb=mouse(l,1)
   lasttime=timer
   gui cursor x,y
 endif
 MM.CURSOR=-1
 if t=1 then
   MM.CURSOR=lb
 elseif t=2 then
   if lb then MM.CURSOR=x
 elseif t=3 then
   if lb then MM.CURSOR=y
 elseif t=4 then
   MM.CURSOR=lb
 else
   MM.CURSOR=lb
 endif
end function
'
sub mm.beep beeptime as integer
 if beeptime and mm.info(sound)="OFF" then play tone 600,600,beeptime
end sub
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 430
Posted: 03:47pm 25 Jul 2021
Copy link to clipboard 
Print this post

Hi, first thanks for the update.  When I run the "GUI demo program" I get an error

error in line 28 1 is invalid (valid is 1 to 0)

Font 2,2 : GUI Caption c_head, "Pump Control", 10, 0

I do not know why.

I am trying to find a definitive reference to the new GUI commands.  Would it be best to find and download the MM+ manual?
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8572
Posted: 03:53pm 25 Jul 2021
Copy link to clipboard 
Print this post

  Quote  When I run the "GUI demo program" I get an error
error in line 28 1 is invalid (valid is 1 to 0)


  Quote  Space for the controls must be provided using the OPTION MAXCTRLS n command
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 430
Posted: 04:03pm 25 Jul 2021
Copy link to clipboard 
Print this post

  matherp said  
  Quote  When I run the "GUI demo program" I get an error
error in line 28 1 is invalid (valid is 1 to 0)


  Quote  Space for the controls must be provided using the OPTION MAXCTRLS n command


Yes, I have options mouse and option maxctrls set as on and the first mouse demo works just fine.  The first Demo listed elsewhere here does work.  Thanks.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8572
Posted: 04:11pm 25 Jul 2021
Copy link to clipboard 
Print this post

  Quote  option maxctrls set as on


You are supposed to be setting a number e.g. 100. on is being treated as variable with value 0

If that doesn't work do an OPTION RESET and reset up things

Also split the line to separate the font command just so we can be sure what is wrong
Edited 2021-07-26 02:19 by matherp
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 430
Posted: 04:42pm 25 Jul 2021
Copy link to clipboard 
Print this post

Thanks that did it.  I was thinking (wrongly) that it was just a 0 or 1 to turn on so I was just doing option maxctrls 1 but looking at it logically it does SAY MAX, so yah dunderhead here.  Thanks for your time. I did go get the MM+ manual so I can read up on this.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8572
Posted: 04:47pm 25 Jul 2021
Copy link to clipboard 
Print this post

Glad its working - we will make sure the usage of the OPTION is clear in the manual
 
Arno
Newbie

Joined: 19/09/2020
Location: Germany
Posts: 15
Posted: 08:29pm 25 Jul 2021
Copy link to clipboard 
Print this post

On my CMM2, Gen2 with the var save/restore problem I get:

Saved VARS corrupt - memory cleared

Test Program:

option explicit
dim integer a

a=10
var save a
var restore
print a

without option explicit, dim integer a, the program runs perfect and prints 10.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5895
Posted: 10:50pm 25 Jul 2021
Copy link to clipboard 
Print this post

If a program ends with the mouse still linked, there is an error next time the program is run.
"Mouse already linked"

We need to UNLINK on exit.

GUI CURSOR ON
CONTROLLER MOUSE OPEN 0
GUI CURSOR link MOUSE
DO:LOOP UNTIL INKEY$<>""
GUI CURSOR unlink MOUSE


but better if the error is ignored?

Jim
VK7JH
MMedit   MMBasic Help
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8572
Posted: 11:25am 26 Jul 2021
Copy link to clipboard 
Print this post

V5.07.01b2

http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip

Fixes an over-enthusiastic error check in VAR RESTORE and clears mouse LINK before running a program
Edited 2021-07-26 23:40 by matherp
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 326
Posted: 02:06pm 26 Jul 2021
Copy link to clipboard 
Print this post

  matherp said  Please download and test V5.07.01b1


Changes from V5.07.00

Full implementation of the GUI controls as per MM+ but using the mouse as the I/F (except GUI BEEP).
NB: the TOUCH function is renamed CLICK.
The mouse must be connected and working for the GUI commands to work and have been set up using the OPTION MOUSE command
Space for the controls must be provided using the OPTION MAXCTRLS n command

New math command
MATH INVERSE array!(), inversearray!()


This returns the inverse of array!() in inversearray!(). The array must be square and you will get an error if the array cannot be inverted (determinant=0)

New math function
MATH(DETERMINANT array!())

returns the determinant of the array. The array must be square



Thank you. This is great! For the inverse, do the arrays have to be different? IOW, would

MATH INVERSE a(), a()


work?
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8572
Posted: 02:16pm 26 Jul 2021
Copy link to clipboard 
Print this post

  Quote   do the arrays have to be different?


Yes

Note typos above

should be

MATH M_INVERSE and
MATH(M_DETERMINANT



Edited 2021-07-27 00:59 by matherp
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8572
Posted: 08:55am 29 Jul 2021
Copy link to clipboard 
Print this post

V5.07.01b3

http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip

Fixes a bug in the new RESTORE functionality
Edited 2021-07-29 19:04 by matherp
 
Arno
Newbie

Joined: 19/09/2020
Location: Germany
Posts: 15
Posted: 05:21pm 29 Jul 2021
Copy link to clipboard 
Print this post

Most of the time I work in mode 12, it gives me a wonderful experience with my monitor, and thank you for implementing the mouse support, I really like it.

When I start the mouse demo program for the first time I have a crystal clear mouse
pointer with a continuous vertical line on the left side.

Whenever I start the program for a second time the vertical line is not continuous drawn, it looks like only every second line is now drawn and I have more flicker on the pointer.
I cannot observe this in mode 1 and switching from mode 12 to mode 1 and back recovers
the mouse pointer.

Best wishes
Arno
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8572
Posted: 05:43pm 29 Jul 2021
Copy link to clipboard 
Print this post

  Quote  When I start the mouse demo program


Please list the program exactly as you run it and all your options
 
toml_12953
Guru

Joined: 13/02/2015
Location: United States
Posts: 326
Posted: 07:38pm 29 Jul 2021
Copy link to clipboard 
Print this post

  matherp said  


I give up. How do you tell the commas from the periods?
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5708
Posted: 08:35pm 29 Jul 2021
Copy link to clipboard 
Print this post

The commas are white on a black background, the periods are a black background with white characters on them. :)

I've sometimes thought that, in these days of colour monitors, they should be different colours...
Mick

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

Joined: 19/09/2020
Location: Germany
Posts: 15
Posted: 08:36pm 29 Jul 2021
Copy link to clipboard 
Print this post

Hello Peter,

> option list
CURRENT Default mode 12 960x540
CURRENT VGA mode 960x540 RGB332
CURRENT DISPLAY 50,100
OPTION USBKEYBOARD DE


GUI CURSOR ON
CONTROLLER MOUSE OPEN 0
GUI CURSOR LINK MOUSE
DO:LOOP


I have written a data logger where the mouse pointer is in front of a box
which fills the whole screen and any movement of the pointer looks really
much better when I do this at the begining of my program:


MODE 1
MODE 12



EDIT:
Please try this in MODE 12, and start the program a second time.
Then point with the mouse into the x and y positions printed on the screen.


GUI CURSOR ON
CONTROLLER MOUSE OPEN 0
GUI CURSOR LINK MOUSE
DO:
IF MOUSE(l,0)=1 THEN
  CLS
  PRINT MOUSE(x,0)
  PRINT MOUSE(y,0)
ENDIF
LOOP

Edited 2021-07-30 07:02 by Arno
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8572
Posted: 10:20am 30 Jul 2021
Copy link to clipboard 
Print this post

V5.07.01b4

http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip

Fixes bug when using mode 12 as the default

dim a(3,3)=(7,9,2,5,0,0,1,1,3,4,-99,0.5,12,16,8,-1)
dim b(3,3)
math m_inverse a(),b()
math m_print b()
dim c(3,3)
math m_mult a(),b(),c()
math m_print c()
? math(m_determinant a())
 
Arno
Newbie

Joined: 19/09/2020
Location: Germany
Posts: 15
Posted: 06:07pm 30 Jul 2021
Copy link to clipboard 
Print this post

Thank you Peter my Data Logger is using the mouse now and  I'm happy.
But I have still some problems using the mouse in MODE 12.

> option list
CURRENT Default mode 12 960x540
CURRENT VGA mode 960x540 RGB332
CURRENT DISPLAY 50,100
OPTION USBKEYBOARD DE
OPTION MOUSE 0,0

Please be aware that OPTION MOUSE 0,0 is now given.

Run the program

GUI CURSOR ON
CONTROLLER MOUSE OPEN 0
GUI CURSOR LINK MOUSE
DO:
IF MOUSE(l,0)=1 THEN
 CLS
 PRINT MOUSE(x,0)
 PRINT MOUSE(y,0)
ENDIF
LOOP


Stop the program with CTRL C and open the editor with F4.
The mouse pointer is again not so good as it should be.
Press ESC to leave the editor and you can see some rest of your code on the screen.
 
     Page 1 of 2    
Print this page
© JAQ Software 2024