debugging log

Hello there,

I’m trying to debug my watch app "kronosGhost", I've built for my device, an EDGE 520 and unchecked build release and include debug XML.

I've put kronosGhost.prg and KronosGhost.debug.xml in my APPS folder. Then I've run it and it seems to freeze, by that I mean that I cannot exit the app  (e.g. by pressing the ESC key). (In the simulator everything is fine.)
To debug I've created KronosGhost.txt and CIQ_LOG.txt in the APPS/LOGS folder
But those files remain empty.

  • what you want to do is create a timer, and in the timer callback, do the Ui.requestUpdate().  In DFs, the system calls onUpdate() every second when the DF is visible, but in a device app, it's all up to the app.

  • One more time, thanks jim now the apps almost run well
    I've add a  Sys.println("key "+keyEvent.getKey());) in the function onKeyPressed(keyEvent)
    And the press on the KEY_START don't trigger onKeyPressed

  • KEY_START on a 520 is the right key on the bottom of the device.  KEY_ENTER is at the top on the right hand side..  Are you using the correct one?

  • Yes I use the right key on the bottom of the device
    It works well on the simulator

  • How are you seeing that it doesn't work on the device?  Do you display something when you're recording or not recording?   Is it based on your log file? I'm on the 13.00 FW and works fine for me in my apps. 

  • I've also th FW 13.0
    I debug first with log:

        function onKeyPressed(keyEvent){
        	Sys.println("key "+keyEvent.getKey());
            if( Toybox has :ActivityRecording && keyEvent.getKey()==WatchUi.KEY_START ) {
                if( ( session == null ) || ( session.isRecording() == false ) ) {
                	Sys.println("start recording");
                    session = ActivityRecording.createSession({:name=>"Kronos", :sport=>ActivityRecording.SPORT_CYCLING});
                    session.start();
                    WatchUi.requestUpdate();
                }
                else if( ( session != null ) && session.isRecording() ) {
                	Sys.println("stop recording");
                    session.stop();
                    session.save();
                    session = null;
                    WatchUi.requestUpdate();
                }
                return true;
            }else if( Toybox has :ActivityRecording && keyEvent.getKey()==WatchUi.KEY_ESC){
            		//Sys.exit();
            		if( ( session != null ) && session.isRecording() ){
    	     		    session.stop();
    	                session.save();
    	                session = null;
                    }
            		return false;
            }   	
    	    return true;
        } 
    

    Other keys pressed cause writing in the log
    And, for something visual, I've added that at the end of onUpdate of my View:
    if( Toybox has :ActivityRecording ) {
        if( ( session == null ) || ( session.isRecording() == false ) ) {
    
        }else{
            dc.setColor(Graphics.COLOR_RED,bgc);
            dc.fillCircle(10, 10, 10);
            dc.setColor(fgc,bgc);
            myShapes.draw(dc);
    	}
    }

  • My first thought is that It is broken because I cannot see KEY_START pressed with the Input project from the samples
    But when  I'm on the main screen the key works like a charm, triggering the record of activities
    Is there a way to reset the device?

  • It's likly somethin your code.  Settings>System>Device reset if you want to try.

    About your code.  "has" is useful, but you generally don't want to use it much as it can be expensive.  I'll do the has in initialize() and set a boolean and use that.  Also, the "has": you will always be true.  That's probably something from the very early days of CIQ when some devices only had data fields and watch faces.

  • Thanks for the advice about "has"
    Now after reset "Input" project provided with CIQ works
    But still KEY_START in my app doesn't work

  • Solved KEY_START is not triggered by onKeyPressed but onKey yes
    I don't know if it is a bug or a feature