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.
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 01:18am 10 Sep 2016
Copy link to clipboard
Print this post
I did it a different way by using the IF secs3 > 180 Then CLS etc
in the page1 and page2 routines
However it's still ignoring the IF secs3 > 180 bit
Can someone check the routine for secs3 2 post above and see if it's correct please?
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 02:30am 10 Sep 2016
Copy link to clipboard
Print this post
It's definitely ignoring the IF secs3 > 180
it also ignores IF secs3 =< 180
and ignores any combination I thought of trying
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209
Posted: 04:12am 10 Sep 2016
Copy link to clipboard
Print this post
You can not use an IF statement right after an AND operator.
Also it is better to use the multiline version of the IF statement.
Indentation will help with readability.
[code]
IF Touch(X)>396 AND Touch(X)<(396+150) AND Touch(Y)>0 AND Touch(Y)< (0+30) THEN
IF secs3 > 180 THEN
Page2
ELSE
Page1
ENDIF
ENDIF
[/code]
A tiny speed improvement would be to replace (396+150) with 546 and (0+30) with 30.
Microblocks. Build with logic.
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 04:22am 10 Sep 2016
Copy link to clipboard
Print this post
Thanks Jean
Is there any way to stop the touch working after its been touched?
in my code, it's doing what I want it to do but it keeps doing it
I'd like to disable the touch for a period of maybe 5 seconds after the screen has been touched
I've used this for the touch for the 2 "sections of screen with options on it"
[code]IF Touch(X)>255 AND Touch(X)<(395) AND Touch(Y)>0 AND Touch(Y)< (30) THEN
IF secs3 > 180 THEN
Page1
ELSE
mainpage
ENDIF
ENDIF
IF Touch(X)>396 AND Touch(X)<(546) AND Touch(Y)>0 AND Touch(Y)< (30) THEN
IF secs3 > 180 THEN
Page2
ELSE
mainpage
ENDIF
ENDIF
[/code]
Edited by lew247 2016-09-11
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 07:02am 10 Sep 2016
Copy link to clipboard
Print this post
I'm REALLY sorry for asking so many questions but
[code][45] ICON$ = "50d.ppm" , ICON1$ = "50d.ppm", ICON2$ = "50d.ppm", ICON3$ = "50d.ppm"
Error: Unexpected text: , ICON1$ Ä "50d.ppm", ICON2$ Ä "50d.ppm", ICON3$ Ä "50d.ppm"
>
[/code]
Why is this happening? it looks like the = has been turned into Ä
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10223
Posted: 07:37am 10 Sep 2016
Copy link to clipboard
Print this post
command separator is a colon not a comma. You can only use a comma in a DIM statement.
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209
Posted: 07:39am 10 Sep 2016
Copy link to clipboard
Print this post
If it is at the start don't forget the DIM statement.
[code]
DIM ICON$ = "50d.ppm" , ICON1$ = "50d.ppm", ICON2$ = "50d.ppm", ICON3$ = "50d.ppm"
[/code]
or if it is in your program and you need to set a few variables use a :
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 09:03am 10 Sep 2016
Copy link to clipboard
Print this post
Thanks Peter, the comma was the problem
Jean for once I had the dim statements right, thanks though
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 11:30pm 11 Sep 2016
Copy link to clipboard
Print this post
What am I doing wrong? It's more than likely me getting mixed up between string, integer and float again
I want to print BOTH dir1$ and dir1a$
[code]dir1$ = FieldArray$(9)
dir1a = dir1$
Select Case dir1a
case 349 to 360
dir1a$ = "North"
case 0 to 11
dir1a$ = "North"
case 12 to 33
dir1a$ = "NNE"
case 34 to 56
dir1a$ = "NE"
case 57 to 78
dir1a$ = "ENE"
case 79 to 101
dir1a$ = "East"
case 102 to 123
dir1a$ = "ESE"
case 124 to 146
dir1a$ = "SE"
case 147 to 168
dir1a$ = "SSE"
case 169 to 191
dir1a$ = "South"
case 192 to 213
dir1a$ = "SSW"
case 214 to 236
dir1a$ = "SW"
case 236 to 258
dir1a$ = "WSW"
case 259 to 281
dir1a$ = "West"
case 282 to 303
dir1a$ = "WNW"
case 304 to 326
dir1a$ = "NW"
case 327 to 348
dir1a$ = "NNW"
CASE ELSE
dir1a$ = "---"
END SELECT
print dir1a$[/code]Edited by lew247 2016-09-13
jman Guru Joined: 12/06/2011 Location: New ZealandPosts: 711
Posted: 11:57pm 11 Sep 2016
Copy link to clipboard
Print this post
dir1a = dir1$
dir1a needs to be a string
Regards
Jman
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 12:30am 12 Sep 2016
Copy link to clipboard
Print this post
deleted*Edited by lew247 2016-09-13
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209
Posted: 12:38am 12 Sep 2016
Copy link to clipboard
Print this post
I am not able to test this at the moment,
but something like this should work.
(It expects a number from 0 - 359)
There might be a need to add 1 to the formula to get the right index. Depending if the array is zero or one based.
[code]
FUNCTION GetDirection(Dir)
LOCAL Directions AS STRING = ("N,"NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW")
GetDirection = Directions( INT(Dir /22.5 + 16.5) MOD 16) )
END FUNCTION
[/code]
[code]
Print GetDirection(24)
[/code]
Test it with some values to see if it is correct.
I can test this tomorrow when i have access to a umite.
Edited by MicroBlocks 2016-09-13Microblocks. Build with logic.
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 01:22am 12 Sep 2016
Copy link to clipboard
Print this post
Thanks Jean, I've sent you a message with the relevant section of code I'm using to try and get the degrees in both numerals and words.
Phil23 Guru Joined: 27/03/2016 Location: AustraliaPosts: 1667
Posted: 01:26am 12 Sep 2016
Copy link to clipboard
Print this post
That's a really cool bit of code MB.
Got it to work with a few minor changes to test.
[Code]For n=0 to 359
Print n, GetDirection(n)
Next
FUNCTION GetDirection(Dir As Integer) as String
LOCAL Directions(15) AS STRING =("N","NNE","NE","ENE","E","ESE","SE","SSE","S","SSW","SW","WSW","W","WNW","NW","NNW")
GetDirection = Directions((INT(Dir /22.5 + 16.5) MOD 16))
END FUNCTION[/code]
Seems to report fine.
Phil.
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 01:33am 12 Sep 2016
Copy link to clipboard
Print this post
Phil, thanks for that
Unfortunately I can't figure out how to get it to work here
dir1$ is what the micromite is receiving from the ESP and it is a number in degrees for example 248.7
IF I DIM DIR AS INTEGER it doesn't work
if I DIM DIR AS STRING it does, but the function wont.
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209
Posted: 02:21am 12 Sep 2016
Copy link to clipboard
Print this post
Thanks Phil!
Without a micromite little errors are made easily. I just wrote it down here as a post without testing. :)
Lewis,
You need to change it from a string to an float or integer first
[code]
DirValue = VAL(dir1$)
or
DirValue = INT(VAL(dir1$))
[/code]
You then use that number to call the function
[code]
Direction$ = GetDirection(DirValue)
Print Direction$
[/code]
Microblocks. Build with logic.
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 02:31am 12 Sep 2016
Copy link to clipboard
Print this post
Thanks, I had no idea how to turn a string to integer
But I'm confused as to what DirValue is
Well I know it's the value of dir1$ but where does it relate to the function?
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209
Posted: 02:51am 12 Sep 2016
Copy link to clipboard
Print this post
You use DirValue (which holds the numerical value of the string you got from the com port).
The function expects a number so you need to convert the string into a number first.
You can not use the function by using dir1$ as a parameter but you can with DirValue.
This will not work:
[code]
Direction$ = GetDirection(dir1$)
[/code]
this does:
[code]
Direction$ = GetDirection(DirValue)
[/code]
or all on one line:
[code]
Direction$ = getDirection(INT(VAL(dir1$)))
[/code]
Microblocks. Build with logic.
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 03:07am 12 Sep 2016
Copy link to clipboard
Print this post
Microblocks, your a star
Thank you
and Thank you everyone else
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 10:27pm 13 Sep 2016
Copy link to clipboard
Print this post
Here's an interesting question for you all
How can I do this?
[code]SUB GMT
IF DATE$ = "30-10-2016" AND TIME$ = "02:00:00" THEN
TIME$ = "01:00:00"
END SUB[/code]
The problem I have is the time will continually loop back 1 hour, I want to change the time just once but not the 2nd time that the TIME£ = 02:00:00
Page 11 of 25
Print this page
The Back Shed's forum code is written, and hosted, in Australia.