Avatar for Philip

Philip

Member since May 2023 • Last active Aug 2023
  • 6 conversations
  • 19 comments

Most recent activity

  • in Bangle.js
    Avatar for Philip

    I was looking at the datasheet for the accelerometer in the bangleJS2 and was wondering about the magnitude range that is available.

    https://www.espruino.com/datasheets/KX02­3-1025.pdf

    I see there is a +/- 2, 4, and 8g sensitivity setting that is 'user selectable':

    "Resolution and acceleration ranges are user selectable via I2C or SPI." (I don't know much about these protocols)

    But I am wondering how / if we can interact with that through the API and also what the 'default' setting is.

    At the moment, through experimentation, I haven't been able to produce a reading above 5.65 g's (total magnitude). I could see that reading coming from a combination of axes though, which leads me to think the accelerometer is in 4g mode, however it is possible that my timid nature / feeble physique are imposing the limit here, not the sensor (lol)

    EDIT: I may be finding what I need over in
    https://github.com/espruino/BangleApps/b­lob/master/apps/accelrec/app.js

    Using deduction, it seems like you CAN change those things with accelWR, the default is 4gs, and you just need to find the right numbers in the datasheet that correspond with the setting you want to change. I actually think I have what I need - just have to review the data sheet in more detail.

    EDIT: again. I think I have everything I need. Thank you Espruino forums for being a rubber duck for me :)

    So here's the D/L for anyone else that comes by.

    The default is definitely 4g's. You configure the accelerometer by writing to these eight bit binary numbers called "registers". The two important registers in the manual I referenced are called "ODCNTL" and "CNTL1". References for these are on pages 40 and 44 of the manual.

    Once you change the sensitivity of the sensor, your magnitude numbers from bangle will either be 0.5 at rest of 2.0 at rest (instead of 1.0), so correct for that accordingly.

    My goal was to measure peak throw acceleration, but I think humans can pull of 10's of g's when throwing objects so I might be out of luck with even the 8g setting.

  • in Bangle.js
    Avatar for Philip

    So actually I may have solved my problem entirely, but I'd be happy to hear from people as to why I solved it, because I think I Maxwell Smart'ed / Mr. Magoo'ed my way through it.

    The code I am running now

    Bangle.setUI({mode: "custom", btn: () => {
      Bluetooth.println("");
      Bluetooth.println(JSON.stringify({t:"inf­o",msg:"Hello World"+getTime()}))
      console.log("HELLO");
    }})
    
    function GB(argumentados) {
      g.clear();
      g.drawString(JSON.stringify(argumentados­),0,0,true)
    }
    

    with the android integration uninstalled works PERFECTLY. I noticed that in the android integration there was a random looking Bluetooth.println("") hanging out above the send stuff to gadgetbridge code so I added that to mine, and that made it work. TAH DAH.

    I get the info popup every time on the phone. I get the simulated notifications from GadgetBridge drawn on the screen. It's magnificently simple. I'm very happy.

    Edit: okay it's not EVERY time I press the button that I see the toast message, but it's like 80%. Which is good enough.

  • in Bangle.js
    Avatar for Philip

    However, when checking the log it does show multiple presses. So it does seem to be receiving them from the bangle, just not showing them in Android every time.

    Thanks for confirming. This is sort of what I suspected. Like maybe android is debouncing them somehow to avoid spamming the end user or something.

    For Bluetooth print line you shouldn't need it, but I could be wrong.

    Yeah that's what I thought but it doesn't seem to work at all if I uninstall the android integration app from the Bangle. Admittedly I am in a little over my head with this right now, but will probably understand it better after learning a bit more about how everything works.

    I agree that simple transmission seems to work without the app on the Bangle side, but gadget bridge doesn't seem to acknowledge them (even once, like when the app is installed). I'm guessing there's something in the integration app that might facilitate that.

  • in Bangle.js
    Avatar for Philip

    Hey folks! Have been fiddling with the integration aspect of my BangleJS and have been struggling a little bit to figure out what's what. I have been following this:

    https://www.espruino.com/Gadgetbridge

    I installed the bangle version of gadgetbridge on my phone, then installed the android integration on my BangleJS (not 100% sure if this was required for transmit only, but I did it anyway).

    Then I loaded this code into ram in the web IDE:

    Bangle.setUI({mode: "custom", btn: () => {
      Bluetooth.println(JSON.stringify({t:"inf­o",msg:"Hello World"+getTime()}))
      console.log("HELLO");
    }})
    

    disconnected from the web IDE, then connected to GadgetBridge. I then hit the side button on my watch, and saw the little info toast pop up on my phone. Wohoo! Then I hit the button again... Nothing! Strange.

    I hit the button a few more times over the course of about 10 minutes and it seemed to work maybe once or twice more. I proceeded to disconnect from gadgetbridge then reconnect, hit the button again, and it works again - but only once.

    Wonder if anyone with a little more familiarity with these things could weigh in.

    1. Is this unexpected, or am I doing something wrong?
    2. Did I actually need the full android integration app with all the message and message icon dependencies to send info messages to the phone? (It didn't seem to work before I did that, but the integration app only mentions receiving messages, not sending them.)

    My interest right now is just getting the most minimalistic possible setup and get a little bit of hello world data to reliably go both ways, even just to log it to the console.

  • in Bangle.js
    Avatar for Philip

    I am working on an app where it makes sense to immediately turn off the LCD screen backlight after the user has touched the screen. I have found ways to do this, but only with side effects, so I was hoping someone might be able to point me in the right direction. Here's what I've tried:

    1. Bangle.setLCDPower(false) : This turns off the backlight temporarily like I want... but also turns off the sunlight-readable display forever unless I turn it back on. Not really what I want. Just want to hit the backlight.
    2. Bangle.setLCDBrightness(0): This turns off the backlight! Yay! ... forever. Boooooo.

    I am hoping to just say "Hey turn off the backlight right now, and otherwise continue operating like normal".

    One possible solution I thought of, but seems a lot more hacky than it should be is:

    const prev = Bangle.getOptions().backlightTimeout; // record current setting
    Bangle.setOptions({backlightTimeout: 1}); // Timeout to 1ms
    setTimeout(() => Bangle.setOptions({backlightTimeout: prev}), 100); // resume previous setting
    

    Is that the best way to do this right now?

  • in Bangle.js
    Avatar for Philip

    I am running default apps on my Bangle right now - I do have one custom app I am working on, but it doesn't interact with bluetooth.

    so you think without the Logitech keyboard it all works? To be honest it sounds a lot like a Bluetooth driver issue on your PC.

    Yeah if I turn off the logitech keyboard everything works perfectly - and it only needs to be off at the moment the bangle connects, then I can turn it right back on. I'm interested in the idea it might be something with the bluetooth driver on my PC. I have a couple other bluetooth devices - a keyboard, a camera, and some speakers (all are typically disconnected). If the same issue does not happen with them it might suggest its specific to this keyboard. I'll also see if there are any driver updates out there.

    Utimately, the issue is very small for me now - it's extremely easy to work around, just a flick of a switch and then back one second later. Happy to help with additional diagnostics but just want to make sure the lack of urgency on my end is clear.

    Edit: Ooh I can also try with my phone, since that has bluetooth as well - eliminate the PC from the equation. Will report back if I find out anything useful.

Actions