• Arduino Powered PC Lighting

    arduino led ws2801
    2
    2 Posts
    1k Views
    ScuzzS
    Code for the test. #include "FastLED.h" #define NUM_LEDS 41 #define DATA_PIN 11 #define CLOCK_PIN 13 CRGB leds[NUM_LEDS]; void setup() { FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS); } void Pulse(CRGB colour) { for(int i = 0; i < NUM_LEDS; i++) { leds[i] = colour; leds[i].maximizeBrightness(); } FastLED.show(); for(int i = 0; i < 14; i++) { for(int k = 0; k < NUM_LEDS; k++) { leds[k].fadeLightBy( 64 ); } FastLED.show(); delay(50); } for(int i = 0; i < 14; i++) { for(int k = 0; k < NUM_LEDS; k++) { leds[k] *= 2; } FastLED.show(); delay(100); } } void UpDown(CRGB colour) { for(int i = 0; i < NUM_LEDS; i++) { leds[i] = colour; FastLED.show(); leds[i] = CRGB::Black; delay(30); } for(int i = NUM_LEDS-1; i >= 0; i--) { leds[i] = colour; FastLED.show(); leds[i] = CRGB::Black; delay(30); } } void loop() { UpDown(CRGB::Red); UpDown(CRGB::Red); for(int i = 0; i < 5; i++){ Pulse(CRGB::Red); } UpDown(CRGB::Purple); UpDown(CRGB::Purple); for(int i = 0; i < 5; i++){ Pulse(CRGB::Purple); } UpDown(CRGB::Blue); UpDown(CRGB::Blue); for(int i = 0; i < 5; i++){ Pulse(CRGB::Blue); } }
  • How the shoutbox client sockets work

    1
    1 Posts
    723 Views
    SchamperS
    This is about the following file: sockets.js We need more posts, why not write something about how the shoutbox works? Could be interesting for some people I suppose :P The fun thing about the recent refactor of the client sockets is that you can call them by simple doing Shoutbox.sockets.<action>(data, callback);. This is possible because we add each message to the global Shoutbox.sockets object. Doing this for every single message would take a lot of time and code, especially with the recent addition of commands. So how do we do this? As you can see at the beginning of the file there are 2 objects with a bunch of method names as key and socket events as value, these names will later be used as the <action>: var Messages = { getShouts: 'plugins.shoutbox.get', sendShout: 'plugins.shoutbox.send', removeShout : 'plugins.shoutbox.remove', editShout: 'plugins.shoutbox.edit', notifyStartTyping: 'plugins.shoutbox.notifyStartTyping', notifyStopTyping: 'plugins.shoutbox.notifyStopTyping', getOriginalShout: 'plugins.shoutbox.getOriginalShout', saveSettings: 'plugins.shoutbox.saveSetting', getSettings: 'plugins.shoutbox.getSettings', getUsers: 'user.loadMore', getUserStatus: 'user.isOnline' }; var Events = { onUserStatusChange: Messages.getUserStatus, onReceive: 'event:shoutbox.receive', onDelete: 'event:shoutbox.delete', onEdit: 'event:shoutbox.edit', onStartTyping: 'event:shoutbox.startTyping', onStopTyping: 'event:shoutbox.stopTyping' }; These are the default messages and events we work with. Extra events or messages required for commands etc are defined by the command itself (we get to this later). After that we have a Handlers object, which essentially has all the default socket handlers required for the shoutbox to actually work. You can see some basic stuff ilke onReceive, onDelete etc. You can pretty much guess by their name what their function is. Interesting here is the defaultSocketHandler: var Handlers = { onReceive: ..., onDelete: ..., onEdit: ..., onUserStatusChange: .., onStartTyping: ..., onStopTyping: ..., defaultSocketHandler: function(message) { this.message = message; var self = this; return function (data, callback) { if (typeof data === 'function') { callback = data; data = null; } socket.emit(self.message, data, callback); }; } }; In the next bit I explain how the defaultSocketHandler works. At the very end of the file we find what we actually “expose” to the public/global Shoutbox object. Shoutbox.sockets = { messages: Messages, events: Events, registerMessage: function(handle, message) { if (!Shoutbox.sockets.hasOwnProperty(handle)) { Shoutbox.sockets[handle] = new Handlers.defaultSocketHandler(message); } }, registerEvent: function(event, handler) { if (socket.listeners(event).length === 0) { socket.on(event, handler); } }, initialize: function() { for (var e in Events) { if (Events.hasOwnProperty(e)) { this.registerEvent(Events[e], Handlers[e]); } } for (var m in Messages) { if (Messages.hasOwnProperty(m)) { this.registerMessage(m, Messages[m]); } } } }; The first two keys, messages and events simply expose the default messages and events that we talked about at the beginning. registerMessage is more interesting. Let’s take a closer look at it. registerMessage: function(handle, message) { if (!Shoutbox.sockets.hasOwnProperty(handle)) { Shoutbox.sockets[handle] = new Handlers.defaultSocketHandler(message); } }, registerMessage first checks if we don’t already have the requested key in the Shoutbox.sockets object, if we don’t it adds a new key with a new defaultSocketHandler as value. We pass the message from the second argument to the defaultSocketHandler constructor, which, if you scroll up, is stored in the newly created object with this.message = message;. If you look at the return value of defaultSocketHandler you can see that it returns a function that takes 2 arguments. This function essentially just emits a socket message with the data and callback as arguments. Because we store this newly created function as the value of the Shoutbox.sockets[handle] key, this allows us to do the Shoutbox.sockets.<action>(data, callback); from the beginning of this post. registerEvent just registers a new event with socket.io for the passed in event and handler. intialize simply loops over all the Events and Messages and calls the appropriate functions to register all the default events and messages. Because we expose registerMessage and registerEvent commands and actions can easily add their own methods and event handlers to the Shoutbox.sockets object. Hopefully this post was somewhat interesting to read ;)
  • (Web)design showcases

    7
    7 Posts
    1k Views
    AntuA
    @theDaftDev Welcome, it looks great now ! :)
  • Polls

    7
    7 Posts
    1k Views
    SchamperS
    0.0.2 is on npm, so you can update.
  • Pole

    5
    5 Posts
    998 Views
    SaNiTYs_EnDS
    atleast we finally getting one
  • This topic is deleted!

    Locked
    1
    1 Posts
    1 Views
    No one has replied
  • This topic is deleted!

    Locked
    1
    1 Posts
    4 Views
    No one has replied
  • status updates

    12
    12 Posts
    1k Views
    LeoL
    i shouted in ya mums box last night m8 but nah, i dont think so.
  • nodebb-plugin-webrtc

    1
    1 Posts
    617 Views
    SchamperS
    I made another thing. Just wanted to get this (working) out on Github so that other people can hopefully contribute… It’s been a bitch. https://github.com/Schamper/nodebb-plugin-webrtc
  • Logo

    5
    5 Posts
    835 Views
    LeoL
    working on one atm
  • Youtube / Twitch page

    1
    1 Posts
    479 Views
    ScuzzS
    Now @leo is uploading some videos I think it might be best to have some sort of dedicated page where he can submit his own links and they will appear on a separate page. Instead of having them all in a thread. Do you think this would be something a plugin could and should do or do you think a simple html page would suffice? I know bootstrap will be useful with the layout for the page; I have a few ideas on how i would like it set out.
  • nodebb-plugin-buzzer

    1
    1 Posts
    479 Views
    SchamperS
    So for the sake of creating something silly I made this little plugin. It’s add a nice button called ‘Buzz’ next to the Send button in the chat modal. When pressed, the other user will have their modal shaken all about and an annoying little nostalgic sound will play! To prevent users from losing their sanity these are the limitations: You can only buzz a user if you both have the chat window open (this is very much intentional to keep it from being too annoying) A buzz will last about 1 second, and you can only buzz every 2 seconds. (this is very much intentional to keep it annoying, but not too annoying) Have fun :D npm install nodebb-plugin-buzzer Source: https://github.com/MrWaffle/nodebb-plugin-buzzer
  • [nodebb-theme-seawolf] A dark theme for NodeBB

    1
    1 Posts
    910 Views
    ScuzzS
    Hi guys, Here is a theme I have been working on for NodeBB. It’s based on the Vanilla theme. I found the colour scheme at https://kuler.adobe.com/ which has some very nice colour schemes. It’s worth checking out. Screenshots of the theme: [image: ZeTsVe5.png] [image: zjzhF1B.png] [image: 4t5oojS.png] This is a work in progress so expect some bugs and some ugliness until I can sort them out. The admin panel need work but I’m hoping to sort that out soon. This is my first time doing anything like this so be kind :) Github: https://github.com/BitBangersCode/nodebb-theme-seawolf Live Demo: http://bitbangers.co.uk
  • Project Honeypot plugin?

    1
    1 Posts
    801 Views
    SchamperS
    It looks like the NodeBB community really wants an anti-spam plugin. (http://community.nodebb.org/topic/150/nodebb-anti-spam) Perhaps we can develop a plugin that utilises Project Honeypot? IP that users register with should already be available.
Online Users