B4A Library ABFlicB4A library for Flic buttons

Discussion in 'Additional libraries, classes and official updates' started by alwaysbusy, Mar 7, 2017.

  1. alwaysbusy

    alwaysbusy Expert Licensed User

    You probably have seen these nifty little IoT Flic buttons around. They are a fun and relative cheap BLE button that allows you to do something when the button is clicked, doubleclicked or hold.

    Demo video:

    How to use:
    1. Install the Flic app from the Google Play.
    2. On their developer page, create a new app: you get a key and a secret.
    3. Copy the ABFlicB4A library jar and xml to your library folder and select it in B4A

    Example usage code:
    Sub Process_Globals
    'These global variables will be declared once when the application starts.
       'These variables can be accessed from all modules.

    End Sub

    Sub Globals
    'These global variables will be redeclared each time the activity is created.
       'These variables can only be accessed from this module.
       Private flic As ABFlic
    Private Button2 As Button
    Private Button3 As Button
    Private Button4 As Button
    Private Label1 As Label
    Private Button1 As Button
    Private MyFlicID As String
    Private FlicResults As List   
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    End Sub

    Sub Activity_Resume
    ' your key and secret
    End Sub

    Sub Button1_Click
    End Sub

    Sub Button2_Click
    End Sub

    Sub Button3_Click
    End Sub

    Sub Button4_Click
    End Sub

    Sub flic_Added(buttonID As String, Name As String)
       MyFlicID = buttonID
    Log("Added: " & buttonID)
       Label1.Text = 
    "Added: " & buttonID & CRLF & Label1.Text
    End Sub

    Sub flic_Clicked(buttonID As String, wasQueued As Boolean, timeDiff As Int)
       MyFlicID = buttonID
    Log("Clicked: " & buttonID)
       Label1.Text = 
    "Clicked: " & buttonID & CRLF & Label1.Text
    End Sub

    Sub flic_DoubleClicked(buttonID As String, wasQueued As Boolean, timeDiff As Int)
       MyFlicID = buttonID
    Log("DoubleClicked: " & buttonID)
       Label1.Text = 
    "DoubleClicked: " & buttonID & CRLF & Label1.Text
    End Sub

    Sub flic_Holded(buttonID As String, wasQueued As Boolean, timeDiff As Int)
       MyFlicID = buttonID
    Log("Holded: " & buttonID)
       Label1.Text = 
    "Holded: " & buttonID & CRLF & Label1.Text
    End Sub

    Sub flic_Removed(buttonID As String)
       MyFlicID = 
    Log("Removed: " & buttonID)
       Label1.Text = 
    "Removed: " & buttonID & CRLF & Label1.Text
    End Sub

    Sub flic_Error(err As Int)
    Log("Error: " & err)
       Label1.Text = 
    "Error: " & err & CRLF & Label1.Text
    End Sub
    I'm currently working on a Desktop/Raspberry Pi version of this library, which I will share in the B4J forum later.

    Attached Files:

  2. bluedude

    bluedude Well-Known Member Licensed User

    Pretty cool these buttons but you always need a device nearby and that is the weak point.
  3. alwaysbusy

    alwaysbusy Expert Licensed User

    Indeed. Luckely I have a device about every 5 meters in my home...;) Haven't tried the distance they can cover. They claim about 50m, but I seriously doubt that.
    Cableguy and DonManfred like this.
  4. DonManfred

    DonManfred Expert Licensed User

    It is especially this from your post which i liked :D
    alwaysbusy likes this.
  5. sorex

    sorex Expert Licensed User

    probably 50m in open air. with brick walls or concrete ceilings it's probably a lot less.

    nifty things tho, didn't see it before.
  6. tigrot

    tigrot Well-Known Member Licensed User

    I know those devices from the first times(when they were a pjt), but apart from being a gadget I don't find any utility for them. I have 4 of them but after first tests they are still in their box. Did anybody find a use for them, apart from draining batteries?
  7. alwaysbusy

    alwaysbusy Expert Licensed User

    @tigrot I've seen your posts. Did you ever get it working without the Flic app?

    I have one in use currently: to regulate the brightness of my lamps. One click is full brightness, doubleclick is dim (movie setting), hold is turn the light off. I'm using it together with philips HUE bridge/lamp. It is sticked under my coffee table, because picking up the iPad to regulate the lights is just ridiculous. After all we don't live in the dark ages any more, no? ;)

    Flow: press button -> Flic app on iPad -> HUE Bridge -> Lamps

    Uses about 2 extra cables to make the lamp 'wireless'...:rolleyes:

    But I'm sure I'll find some other weird uses for it :), I was thinking of using them as a cheap location beacons around the house.
  8. alwaysbusy

    alwaysbusy Expert Licensed User

    Just a photo to show how my living room is currently looking. You have to imagine the black box on the left houses 3 more linux boxes, a couple of Raspberry Pies, routers, hubs, TV boxes, NAS and I don't how many miles of cables. My cleaning lady Madeleine (which is a Roomba), refuses to clean this room...

  9. tigrot

    tigrot Well-Known Member Licensed User

    Hi AlwaysBusy,
    It's a normal BLE device, you can use directly from android. The support APP from the flic company is to mantain a link between the android/IOS device. The Flic sends a packet on pressure and the support App generates the appropriate events.
    I generally build my hardware to support my apps, since I love integrating systems(I have been doing it since 1972).
    There are so many ready to use dimmers and BLE device that it's not worth to further study about it, but if it's an hobby, it's OK...
    alwaysbusy likes this.
  10. tigrot

    tigrot Well-Known Member Licensed User

    Nice living! My wife would kill me If I spread cables around. I have a wide experiment room on groud floor of my two floors house, so I'm almost free to experiment my hobbies.
  11. tigrot

    tigrot Well-Known Member Licensed User

    Tell me more if you can bypass flic manager. This was one of the main reason I gave up with it.
    Thank you!
  12. alwaysbusy

    alwaysbusy Expert Licensed User

    @tigrot I will. From what I read they have a seperate SDK which does not use the flic app, but you have to order 1000+ buttons to get access to this SDK. So I suspect it will not be easy :confused:
  13. tigrot

    tigrot Well-Known Member Licensed User

    They never separate Flic from their App. The SDK must connect to their APP. You must request an APP auth code to start with you APP. Use BLE library and you'll bypass their app.
    Cableguy likes this.
  14. Cableguy

    Cableguy Expert Licensed User

    The ESP8266-12F is not the smallest form for the esp8266 based boards, and is still quite small and can cover more than 300mt (max at 900m in open space without dropping packages) so why not 50m for that thing?
  15. alwaysbusy

    alwaysbusy Expert Licensed User

  16. tigrot

    tigrot Well-Known Member Licensed User

    There are also simillar products related to BLE or previous version of bluetooth, with the same format. They have also digital I/O to help to sense switches with no external processor added. I tested many with interesting results.
  17. tigrot

    tigrot Well-Known Member Licensed User

  18. dibesw

    dibesw Active Member Licensed User

    Ciao Mauro, vorrei capire meglio come utilizzare questi flic buttons.
    Posso chiederti qualche informazione?

  19. tigrot

    tigrot Well-Known Member Licensed User

    Scritto in privato
  20. andyr00d

    andyr00d Member Licensed User

    Looking forward to the B4J version! this could certainly be useful running from a NAS or Pi etc
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice