Show Posts
|
|
Pages: [1] 2 3 ... 25
|
|
1
|
Products / Arduino Due / Re: Due GUI
|
on: May 18, 2013, 11:48:10 am
|
|
Well I've had a useful day with the library. There was a bug that was corrupting the variables and causing hours of wasted time but I've fixed it now!
Anyway new additions to the working objects list:
addInputBox !!! drawInputBox updateInputBox updateLabel (automates the sequence.. if variable has changed then remove old value,display new value, update object. setColorLong (these new colour commands allow setting of a colour using 1 long int in the form 0xFFFFFF where value is 0xRRGGBB setBackColorLong having it as one value makes it easy to have presets such as clrBlack,clrBlue,clrYellow etc)
This scrolls the screen up so that the object is visible in the top half of the screen and displays a keyboard at the bottom half of the screen. The keyboard is definable with a caps key and a symbol key allowing 3 full 52 key keyboards.
So we are nearing the point where it is alpha testable.....
I need to write a manual for it first but as my code is very heavily remarked that will make it much easier.
There are still parts not finished but I will highlight those in the manual.....
|
|
|
|
|
2
|
Using Arduino / Programming Questions / Re: delay() & equivalent not working.
|
on: May 18, 2013, 11:38:52 am
|
Sorry, posting 5500+ lines of code would have been silly when this was more out of interest than anything else. Someone was able to come up with the solution without the code. I am more than happy to jump in and help others and usually the code is necessary but on this occasion it would have been ott.
I'm certain that it would have been possible to demonstrate the problem in considerably less than 5500 lines of code. Just the act of doing so would probably have been enough for you to spot the problem on your own. In any case, posting a minimal sketch that actually demonstrated the problem would have avoided relying on some inspired guesswork by majenko and would have avoided everyone else looking at this thread from wasting time trying to guess what you were doing. If you had posted a short sketch demonstrating the problem, it would have been blindingly obvious what was causing it. I'm sorry but as I didn't know what was causing the problem it makes building a small sketch that recreates the problem quite difficult! It just seemed odd really and knowing that interrupts stop delay() and millis() working would have made the process of finding the problem instant hence another member knowing what the likely issue was. Like I said, the library was never going to keep the delay in anyway so writing the rest of that function negated the need for it but I was curious as to why it was happening. Anyway I now know what the issue is and anyone reading this will do too so it has been a useful excursion from what I am doing.
|
|
|
|
|
3
|
Using Arduino / Programming Questions / Re: delay() & equivalent not working.
|
on: May 18, 2013, 06:19:35 am
|
You're not using delay() or millis() from within an interrupt are you ...?
Yes, a slow one. Didn't know that was an issue but it does make sense thanks. delay() checks the return value of millis() against a timeout value. millis() returns the value of a counter variable. That counter variable is updated once a millisecond by a timer driven interrupt routine. That interrupt routine cannot run while you are in your interrupt routine, so the counter never increases. Interrupt routines should be kept as short as possible so that other interrupts have a chance to fire. The "proper" way of doing what you want is to set a flag (and maybe a couple of variables - x/y coordinates for example) in the interrupt routine, and then watch for that flag being set in the main loop. Only in the main loop would you do slow and intensive operations like drawing widgets on a screen. You need to separate the "capturing" of the event and the "reacting to" the event. The capturing is done in the interrupt by setting a flag that says this event has happened. The reacting to is done in the main loop by it realising that the event happened recently, so it does what is needed. The capturing wants to be instant and reliable (interrupt) but the reacting to can be slightly delayed by a few milliseconds without any adverse consequences (and maybe not even being noticable) - the event has already been captured. Thanks for your reply but I actually already understand all this anyway. My interrupt handler is very short and uses its own interrupt on the Due (checked beforehand to make sure it was clear), if it detects an event it needs to deal with then it halts the interrupt whilst it updates the screen etc then restarts it. Thanks to everyone who tried to help but majenko got it.. the only thing here I didn't realise was that delay() and millis() didn't work inside an interrupt. millis() could have been updated by another interrupt hence me trying to use the loop alternative myself to see if delay() was the issue. It was only done like this as a quick kludge to check the display before connecting the process to the on button press and on button release events.
|
|
|
|
|
4
|
Using Arduino / Programming Questions / Re: delay() & equivalent not working.
|
on: May 18, 2013, 06:10:59 am
|
You're not using delay() or millis() from within an interrupt are you ...?
Yes, a slow one. Didn't know that was an issue but it does make sense thanks. So you're starting to realize why most people ask you to post all of your code rather than just what you think is the problem? Sorry, posting 5500+ lines of code would have been silly when this was more out of interest than anything else. Someone was able to come up with the solution without the code. I am more than happy to jump in and help others and usually the code is necessary but on this occasion it would have been ott.
|
|
|
|
|
5
|
Products / Arduino Due / Re: Due GUI
|
on: May 17, 2013, 08:02:03 pm
|
|
I have a full qwerty keyboard with number pad very nearly finished. This will be for text input boxes. I am hoping that it will be in a fit state to go out for alpha testing within the week. There are dozens of functions added and a demo program which shows them in action. All the object orientated stuff works via an interrupt which is added by the library so you can even end up with the loop function empty!
Anyway will update with more pictures etc soon.
|
|
|
|
|
8
|
Using Arduino / Programming Questions / Re: delay() & equivalent not working.
|
on: May 17, 2013, 02:10:01 pm
|
|
No it's not really part of my code at all! It was a quick hack to replace the delay() function to see why it was happening!
I'm still writing it at the moment and it now works because I now change the key top colour until the user takes the stylus away then change it back so it is working without the delay bit..... The delay bit was only there to test the colour bits and was never staying. It just seemed weird that it would do that at all!
|
|
|
|
|
9
|
Using Arduino / Programming Questions / [sorted] delay() & equivalent not working.
|
on: May 17, 2013, 01:50:58 pm
|
|
I'm writing a library at the moment and wanted to change the colour of an object when pressed....
The following function draws a key and by changing the cap colour and text colour it has the appearance of being pressed:
calckey(key number,clrWhite,clrBlack);
The function works perfectly now if I do the following:
calckey(key number,clrRed,clrWhite); calckey(key number,clrWhite,clrBlack);
It displays the key in red then straight away in white, so fast that you can barely see it in red (as you would expect)....
So now to what I would have done:
calckey(key number,clrRed,clrWhite); delay(15); calckey(key number,clrWhite,clrBlack);
The sketch locks up at the delay.... so I tried:
calckey(key number,clrRed,clrWhite); unsigned long int=now; while (millis()<now+20){}; calckey(key number,clrWhite,clrBlack);
it also crashes !
any ideas??
confused.com
|
|
|
|
|
12
|
Products / Arduino Due / Re: Due GUI
|
on: May 15, 2013, 11:12:54 am
|
Hi and Many thanks for your extensive efforts -
is there any downloadable form or repository where i can download the files for testing and verifying - would be great as you really hit the spot by combining the essential libs to one Gui tooolbox i'm thinking about an Dali based lighting control with an Due and 5" touch display which i will put on the playgroud once i have everything put together - your toolbox would be very helpfull for this project.
Kind regards, Mike
I have got checkboxs and a variant of them called cycleboxs working. I am just working on an input box for text and will then release a downloadable version for testing whilst I finish the other planned bits.I have a demo running here that has three pages and allows people to switch between them and keep the variables consistent etc. The input box effectively scrolls up the part of the screen with the input and creates a keyboard across the bottom half of the screen so quite a bit of work... I will also be adding the option of PS2 and bluetooth keyboard support etc but that is for later.......
|
|
|
|
|
13
|
Using Arduino / Programming Questions / Strange problem with library...
|
on: May 13, 2013, 01:12:59 pm
|
I am working on a library that was working fine yesterday evening but I wanted to change the name so first I backed up the whole library folder by selecting it and zipping it up and then messed with it but kept getting errors so I deleted the folder and reverted to the backup by unzipping the folder back to it's original place (this is a quick backup method I use regularly) BUT I am now getting errors which are silly! This is an example of a call on the current version of the library: DueGUI.addPanel(0,0,799,50,clrBlue,clrWhite,clrWhite,2,"Board control menu",280,8,BVS_34,visible,URNnull);
The final attribute "URNnull" was added yesterday but it was working for hours after being added.... Following being restored from the backup I am now getting the errors (actually I am getting pages of errors in pairs for each call, this is the pair relating to the 1st error): /Users/darren/Documents/Arduino DUEGUI/libraries/UTFT/UTFT.h:294: error: expected ',' or '...' before numeric constant
AND DueGUI_demo_01:178: error: no matching function for call to 'UTFT::addPanel(int, int, int, int, int, int, int, int, const char [23], int, int, int, int, int)' /Users/darren/Documents/Arduino DUEGUI/libraries/UTFT/UTFT.h:301: note: candidates are: int UTFT::addPanel(word, word, word, word, long int, long int, long int, byte, String, int, int, int, bool)
My call in the sketch is calling "addPanel" with 8 ints a string and 5 ints BUT the compiler thinks that the corresponding line in the h file only has 8 ints, a string and 4 ints...... It DID the day before but since last night it has had 5 ints following the string. The actual line in the h file is: int addPanel(word x,word y,word xs,word ys,long colour,long borcolour,long textcolour,byte borwidth,String top,int xo,int yo,int font,bool visible,int URN); and the corresponding line in the cpp file is: int UTFT::addPanel(word x,word y,word xs,word ys,long colour,long borcolour,long textcolour,byte borwidth,String top,int xo,int yo,int font,bool visible,int URN){ This makes no sense as it all worked before..... So I installed the IDE on another fresh computer this time running Windows7 rather than MacOS and with a completely fresh install I get the SAME issue! I thought that it might be looking at an old file but if I go to the latest h file and insert a lot of lines before the error the line number of the error increases so the IDE is looking at the right file. IF I remove the final attribute from the definition in the sketch, h file and in the cpp file the first error: /Users/darren/Documents/Arduino DUEGUI/libraries/UTFT/UTFT.h:294: error: expected ',' or '...' before numeric constant Stays but the other one goes away..... This was working perfectly earlier and it's not now.... I cannot understand what on earth is wrong with it.
|
|
|
|
|
14
|
Products / Arduino Due / Re: Due GUI
|
on: May 11, 2013, 02:14:59 pm
|
|
The current list of functions:
void InitGUI(byte tclk, byte tcs, byte tdin, byte dout, byte irq,int CS_pin, int Rate); void preserveColours(); void restoreColours(); void updatingScreen(); void finishedUpdatingScreen(); bool withinBounds(int chkX,int chkY,int X, int Y, int XS, int YS); String displayNumFormat(int Num,int len); int calculate_x(int angle,int radius); int calculate_y(int angle,int radius); void drawAngledLine(int x,int y,int angle,int radius); void startTimer(Tc *tc, uint32_t channel, IRQn_Type irq, uint32_t frequency); void stopTimer(IRQn_Type irq); void restartTimer(IRQn_Type irq); int addCheckBox(word x,word y,word xs,word ys,long colour,long borcolour,long textcolour,long presscolour,long presstextcolour,byte borwidth,String top,word xo,word yo,int font,int initialstate,bool visible,int URN); int addCycleButton(word x,word y,word xs,word ys,long colour,long borcolour,long textcolour,long presscolour,long presstextcolour,byte borwidth,String top,word xo,word yo,int font,int initialstate,int cyclemin,int cyclemax,int cyclestep,bool visible,int URN); int addButton(word x,word y,word xs,word ys,long colour,long borcolour,long textcolour,long presscolour,long presstextcolour,byte borwidth,String top,word xo,word yo,int font,bool visible,int URN); void drawButton(int buttonnumber); bool checkButton(word buttonnumber); int checkAllButtons(); int addPanel(word x,word y,word xs,word ys,long colour,long borcolour,long textcolour,byte borwidth,String top,int xo,int yo,int font,bool visible); void drawPanel(int objectnumber); int addLabel(word x,word y,long colour,long textcolour,String top,int font,bool visible); void drawLabel(int objectnumber);
int addShape(word x,word y,long colour,int type,int a,int b,int c,int d,int e,int f,int g,int h,int i,int j,bool visible); void drawShape(int objectnumber);
int addImage(word x,word y,int imageNumber,bool visible); void drawImage(int objectNumber);
int addAnalogueClock(word x,word y,word clocksize,word centresize,long facecolour,long borcolour,long hourcolour,int hourlen,long mincolour,int minlen,long seccolour,int seclen,byte borwidth, int options,bool visible); void drawAnalogueClock(int objectNumber); int addDigitalClock_Time(word x,word y,long colour,long textcolour,int options,int font,bool visible); void drawDigitalClock_Time(int objectNumber); int addDigitalClock_Date(word x,word y,long colour,long textcolour,int options,int font,bool visible); void drawDigitalClock_Date(int objectNumber); void drawHands(int objectNumber); void drawAnalogueClock_dividers(int objectNumber,int cx,int cy,int inner,int outer,int number,bool lines); void setObjectTime(int objectNumber,int hh, int mm, int ss); void setObjectDate(int objectNumber,int yyyy, int month, int day, bool dateNorm, bool dateFour); void clearAllObjects(); void redrawAllObjects(); void redrawChangedObjects(); void redrawObject(int objectNumber); void clearObjectArea(int objectNumber); void makeObjectInvisible(int objectNumber,bool redraw); void makeObjectVisible(int objectNumber,bool redraw);
|
|
|
|
|
15
|
Products / Arduino Due / Re: Due GUI
|
on: May 11, 2013, 02:03:37 pm
|
Ok just to let you see how simple it is going to be, here is my demo program commented: This uses just 2 libraries: The DueGUI library and the library for the built in RTC. The following program displays: - a "header" across the top of the screen entitled "Board control menu" with:
- live date to the left of the header.
- live digital clock placed on the header.
- a "check box" button called and titled Testbutton1 with switches between two states "Y" and "N" (options for "true/false" and the traditional box with and without a tick will be added this week)
- a "cycle button" called and titled Testbutton2 - this is a button that cycles between a range of numbers with user changeable step and direction {I'm just finishing this now hence the number not being lined up correctly yet!). (options for using a user's array of Strings will be added soon)
- a "button" called "Remove 1&2" which is a standard button which when pressed makes "test button 1" and "test button 2" invisible then disappears itself making another button called "bring back 1&2" visible instead which reverses "Remove 1&2"
- a "button" called "Refresh" which refreshes the screen
- an "analogue clock" - (there are already lots of options for how it looks including a second segments, 5 minute segments etc etc )
Once setup the user does not need to update the live clocks or do any programming to get the cycle button or checkbox buttons to work. Interupts are created by the library are started automatically. You can see just how to do things with the buttons by looking at the code.  // Due GUI demo //
// // Setup and initialise TFT and Touch #include <UTFT.h> UTFT DueGUI(CTE70); // which is: UTFT TFT1(CTE70,25,26,27,28);
// // Setup for the RTC library #include <rtc_clock.h> RTC_clock rtc_clock(RC); char* daynames[]={"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"}; int hh,mm,ss,dow,dd,mon,yyyy;
// Setup variables for Due GUI
// fast ticks for Due GUI interupt volatile int l; volatile int btnFound;
// user variables for objects int clockDigital,clockDate,clockAnalogue,background,pnlTitle;
// user variables for buttons int btnTB1; #define URNTB1 1 int btnTB2; #define URNTB2 2 int btnRemove; #define URNRemove 3 int btnAdd; #define URNAdd 4 int btnRefresh; #define URNRefresh 5
// user variables for screens
#define main_menu 1
// // DueGUI Interupt handler routine // void DueGUI_tickHandler() { // // We don't want timer called whilst it's being handled. // DueGUI.stopTimer(TC3_IRQn); // // routine is called several times per second ie "ticksPerSecond". // l is incremented each time and by checking this against "ticksPerSecond" // we can make sure that once a second events are only called once per second. // l+=1; // // This is the "once per second" event routine. // if (l==ticksPerSecond){ // second passed l=0; if (DueGUI.anyClockVisible) { rtc_clock.get_time(&hh,&mm,&ss); rtc_clock.get_date(&dow,&yyyy,&mon,&dd); DueGUI.setObjectTime(clockDigital,hh,mm,ss); DueGUI.setObjectDate(clockDate,dd,mon,yyyy,true,true); DueGUI.setObjectTime(clockAnalogue,hh,mm,ss); DueGUI.redrawObject(clockDigital); DueGUI.redrawObject(clockDate); DueGUI.drawHands(clockAnalogue); } } if ((DueGUI.dataAvailable()==true) || (DueGUI.anyButtonPressed==true)){ btnFound=DueGUI.checkAllButtons(); if (btnFound!=-1){ DueGUI_OnButtonPress(btnFound); } } // // Ok interupt handler is finished. // TC_GetStatus(TC1, 0); DueGUI.restartTimer(TC3_IRQn); }
// // DueGUI On button press routine // void DueGUI_OnButtonPress(int btnFound){ int URN=DueGUI.GUIobject_data1[btnFound];
if (URN==URNTB1){ } if (URN==URNTB2){ } if (URN==URNRefresh){ DueGUI.redrawAllObjects(); } if (URN==URNRemove){ DueGUI.makeObjectInvisible(btnRemove,true); DueGUI.makeObjectInvisible(btnTB1,true); DueGUI.makeObjectInvisible(btnTB2,true); DueGUI.makeObjectVisible(btnAdd,true); } if (URN==URNAdd){ DueGUI.makeObjectInvisible(btnAdd,true); DueGUI.makeObjectVisible(btnTB1,true); DueGUI.makeObjectVisible(btnTB2,true); DueGUI.makeObjectVisible(btnRemove,true); } }
// // DueGUI display a new screen // void DueGUI_createScreen(int screen){ // First stop interupts whilst we build screen DueGUI.stopTimer(TC3_IRQn); if (screen==main_menu){ pnlTitle=DueGUI.addPanel(0,0,799,50,clrBlue,clrWhite,clrWhite,2,"Board control menu",280,8,BVS_34,true); btnRefresh= DueGUI.addButton(350,100,120,50,clrBlue ,clrWhite ,clrWhite ,clrRed ,clrWhite ,2 ,"Refresh" ,20,12,BVS_28,true ,URNRefresh); btnAdd= DueGUI.addButton(50 ,250,249,50,clrCyan ,clrWhite ,clrBlack ,clrRed ,clrWhite ,2 ,"Bring back 1&2",50,12,BVS_28,false ,URNAdd ); btnRemove= DueGUI.addButton(50 ,350,249,50,clrGreen,clrWhite ,clrBlack ,clrRed ,clrWhite ,2 ,"Remove 1&2" ,50,12,BVS_28,true ,URNRemove ); btnTB1= DueGUI.addCheckBox(50 ,100,249,50,clrBlue ,clrWhite ,clrWhite ,clrRed ,clrWhite ,2 ,"Test button 1" ,50,12,BVS_28,false,true ,URNTB1 ); btnTB2= DueGUI.addCycleButton(50 ,175,249,50,clrBlue ,clrWhite ,clrWhite ,clrRed ,clrWhite ,2 ,"Test button 2" ,50,12,BVS_28,6,3,9,1,true ,URNTB1 ); clockDigital= DueGUI.addDigitalClock_Time(681,11,clrBlue,clrWhite ,0 ,BVS_34,true); clockDate= DueGUI.addDigitalClock_Date(15 ,11,clrBlue,clrWhite ,0 ,BVS_34,true); clockAnalogue=DueGUI.addAnalogueClock(500,225,270 ,15 ,clrBlack ,clrYellow ,clrRed ,80 ,clrGreen ,90 ,clrWhite ,100 ,15 ,24 ,true); } // ok draw all the new objects that are supposed to be visible DueGUI.redrawAllObjects(); // we can restart the interupts now DueGUI.restartTimer(TC3_IRQn); };
void setup(){ // // Initialise serial on the programming port (this section is for debugging).... Serial.begin(115200); Serial.println("\n\nSERIAL CONNECTED AT 115200\n\n");
// // Initialise for RTC rtc_clock.init(); rtc_clock.set_time(__TIME__); rtc_clock.set_date(__DATE__); // // Initialise DueGUI, touch, interupts etc etc DueGUI.InitGUI(6,5,32,3,2,52,2); // Display "main_menu" screen DueGUI_createScreen(main_menu); }
void loop(){ // // Main program control loop // // Do things here :-)
}
|
|
|
|
|