Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Aug 17 01:43
    @bjorno43 banned @linkin-park
  • Jun 20 21:20
    @bjorno43 banned @shenerd140
  • May 10 09:13
    @bjorno43 banned @zhaokunhaoa
  • Apr 27 19:47
    @mstellaluna banned @zhonghuacx
  • Apr 25 17:12
    @mstellaluna banned @cmal
  • Jan 08 22:00
    @mstellaluna banned @dertiuss323
  • Dec 15 2018 23:36
    @mstellaluna banned @18835579411
  • Dec 13 2018 23:57
    @mstellaluna banned @brandon6190
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:13
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:58
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:15
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
kamransagheir
@kamransagheir
and am supposed to perform these tasks:

2 - Configure the switches (P1.1 and P1.4) as inputs, using pull-up internal resistors. 3 - Configure the LEDs (P1.0 and P2.0, P2.1, P2.2) as outputs. 4 - Initialize LEDs states (all turned off). 5 - Create an infinite loop ("while (1)") after your configurations, where the remaining logic should be implemented. 6 - Continuously poll the switches (with debouncing). 6.1 - When Button 1 is pressed, the selected LED changes (default, RED LED). 6.2 - When Button 2 is pressed, the current LED changes state.

For the RED LED, there are only two states: on and off. This should be performed through bitwise toggling. For the RGB LED, there are 8 states, corresponding to off and 7 different colors. This should be performed through bitwise clearing and setting.
In other words, one button changes between the RED LED and the RGB LED: the other button changes the current state of the current LED, allowing us to turn the RED LED on and off and cycle through all the colors of the RGB LED.

I wrote this but it doesn't work

include <msp.h>

int main(void){
volatile int i;
//disabling watchdog timer
WDTCTL = WDT_A_CTL_PW | WDT_A_CTL_HOLD;

//GPIO function

P1->SEL0 &= (uint8_t)(~((1<<1) | (1<<4)));
P1->SEL1 &= (uint8_t) (~((1<<1) | (1<<4)));

//Set input direction using pull-up internal
//resistors
P1DIR |=  (uint8_t) ((0 << 1) | (0 << 4));
P1->REN |= BIT1;
P1->OUT |= BIT1;


//Configuring the LEDS as outputs

P1DIR |= (uint8_t) ((1 << 0));
P2DIR |=  (uint8_t) ((1 << 0) | (1 << 1) | (1 << 2));

//Initializing LEDS

P1->OUT &= ~BIT0;
P2->OUT &= ~BIT0;
P2->OUT &= ~BIT1;
P2->OUT &= ~BIT2;

//Creating an infinite loop to implement remaining logic
while(1){
    i = 100;
    //Do nothing while it is 0
    while((P1->IN & BIT1) == (P1->IN & BIT4)){}
    //Delay Loop
    while(i > 0){i--;}
    //if the value is still 0; go back to waiting
    if((P1->IN & BIT1) == (P1->IN & BIT4)){
        continue;
    }
    else{
        //real Press: perform required computations

        //When Button 1 is pressed, the selected LED changes(RED LED)
        if(P1->IN & BIT1){
            //if P1 is pressed
                (P1->OUT) ^= (P2->OUT); //XOR on LED1 and LED2
        }

        //When Button 2 is pressed, the current LED changes state.
        if(P1->IN & BIT4){
        //if RED LED, alternate the state
            if(P1->OUT){
                P1->OUT ^= ~BIT0; //toggle the bits
            }
            //If RBG LED is seleceted
            if(P2->OUT){
                //if all colors are off, turn first one on
                if((~BIT0) & ~BIT1 & ~BIT2){
                    P2->OUT &= ~(~BIT0) & (~BIT1) & (~BIT2);
                }
                if((~(~BIT0)) & ~BIT1 & ~BIT2){
                    P2->OUT &= (~BIT0) & ~(~BIT1) & (~BIT2);
                }
                if((~BIT0) & ~(~BIT1) & (~BIT2)){
                    P2->OUT &= (~BIT0) & (~BIT1) & ~(~BIT2);
                }
                if((~BIT0) & (~BIT1) & ~(~BIT2)){
                    P2->OUT &= ~(~BIT0) & ~(~BIT1) & (~BIT2);
                }
                if(~(~BIT0) & ~(~BIT1) & (~BIT2)){
                    P2->OUT &= (~BIT0) & ~(~BIT1) & ~(~BIT2);
                }
                if((~BIT0) & ~(~BIT1) & ~(~BIT2)){
                    P2->OUT &= ~(~BIT0) & (~BIT1) & ~(~BIT2);
                }
                if(~(~BIT0) & (~BIT1) & ~(~BIT2)){
                    P2OUT &= ~(~BIT0) & ~(~BIT1) & ~(~BIT2);
                }
                if(~(~BIT0) & ~(~BIT1) & ~(~BIT2)){
                    P2->OUT &= (~BIT0) & (~BIT1) & (~BIT2);
                }
            }
        }


    }

}    

}

8BitPit
@8bitpitRBX_twitter
Your heart is more than a machine
Pumping blood through your body, doing things you've never seen
Their words come like arrows when they fly
With mechanical precision they can cut you up inside
But you're more than bolts
Like the city's more than steel and stone
Soon your heart is gonna overflow
They push you back down you get up again
Circuits freeze and androids never dream
You're more than a machine
Touchscreens
Fingertips and pretty lights
We go through the scanner sideways
See you on the other side
Your flesh
All your skin and all your bones
Carry all our generations
With the future still unknown
But you're more than bolts
Like the city's more than steel and stone
Soon your heart is gonna overflow
They push you back down you get up again
Circuits freeze and androids never dream
You're more than a machine
But you're more than bolts
Like the city's more than steel and stone
Soon your heart is gonna overflow
They push you back down you get up again
Circuits freeze and androids never dream
You're more than a machine
Oburusule Dunstan
@alsong
How do you get current user geolocation in nodejs
Stephen James
@sjames1958gm
You have to get a library or use a service that will get your location from your IP address.
RS
@RS357
hi all

Here is my code:

const fs = require('fs');
const express = require('express');
const app = express();


app.get('/', (req, res) => {
    res.send('<h1>index</h1>')
});

app.get('/about', (req, res) => {
    res.send('<h1>About</h1>');
});

app.get('/contact-me', (req, res) => {
    res.send('<h1>Contact Me</h1>');
});

app.listen(8080);

For some reason whenever i go to 'http://localhost:8080/' in my browser, my browser DOWNLOADS <h1>index</h1> as an html document

I am really confused as to why
alpox
@alpox
@RS357 Because the browser won't know the content-type of what you send. Try adding res.set('Content-Type', 'text/html') before the .send
RS
@RS357
thanks @alpox
@alpox it is still downloading unfortunatley
this is my code now :

const fs = require('fs');
const express = require('express');
const app = express();


app.get('/', (req, res) => {
    res.set('Content-Type', 'text/html');
    res.send('<h1>index</h1>');
});

app.get('/about', (req, res) => {
    res.set('Content-Type', 'text/html');
    res.send('<h1>About</h1>');
});

app.get('/contact-me', (req, res) => {
    res.set('Content-Type', 'text/html');
    res.send('<h1>Contact Me</h1>');
});

app.listen(8080);
Oburusule Dunstan
@alsong
let s say my json object body is people = {"providers":[]}, how do i check that the providers element is empty or not in nodejs.
Jason Luboff
@JLuboff
@alsong Same way you would check it on the front end..
people.providers.length > 0
Nguyễn Đình Đạt
@datpronguyen
hello
any peoples at here now?
Kaz Baig
@kbaig
sup
Jason Luboff
@JLuboff
Si
RS
@RS357
(reposted from help javascript):

hi all

when i open this in glitch: https://learn.freecodecamp.org/apis-and-microservices/basic-node-and-express/

I can't see the file myapp.js in the file tree (as recommended in this hint: https://guide.freecodecamp.org/certifications/apis-and-microservices/basic-node-and-express/meet-the-node-console/)
can anyone help me to find myapp.js?

Corey Lewis
@cursiv3
@RS357 I'd recommend just cloning the repo from the link instead of using glitch
cloning a repo a working from that using git is a much more "real world dev process"
RS
@RS357
tjanks
@cursiv3 i sorted it
cheers!
Prakash Kumar
@ThePrakashKumar

Why we have to convert a string into JS object then again convert JS object to a string before inserting into message?
Here is code:

req.onload=function(){
  json=JSON.parse(req.responseText);
  document.getElementsByClassName('message')[0].innerHTML=JSON.stringify(json);
};

Challenge's Link

alpox
@alpox
@ThePrakashKumar Well, I guess the challenge only wants you to do this for practice - not because it makes sense in this case as the parse/stringify is basically redundant (reverts itself)
But in most cases when requesting stuff you get JSON back which you first have to parse to make the data useful to you. You would not usually print out that data to a page or so directly :D
Prakash Kumar
@ThePrakashKumar
@alpox thanks! :thumbsup:
RS
@RS357
hi all
anyone here atm ?
i have a question about the mongooseDB exercise
Manuel
@Narshe1412
post the question so anyone that pass by can provide the answer
kamransagheir
@kamransagheir
any java chat room here?
Need help with java structure traversal
in order to search and delete
TreeMap<String, List<TreeMap(String,String)>>
need to access the keys of internal TreeMap, compare and delete them
Manuel
@Narshe1412
do you need a working solution or a efficient one?
lightningudemy
@lightningudemy

Good afternoon all, I am seeking information on where I went wrong with my code. I am receiving an error code stating the public key could not be found.

Here is my backend code:

import {fetch} from 'wix-fetch';  
import {wixData} from 'wix-data';


export function postLoyalty() {
 let options ={
 "headers": {        
 "X-Public": "pk_live_ba43e74df464cbf521dd07ee20443ff754c3afc11adc16df2594facb2147cd76"
        }
  }
 const url = 'https://whisqr.com/api/v1.2/user/customer/';
 const key = '<pk_live_ba43e74df464cbf521dd07ee20443ff754c3afc11adc16df2594facb2147cd76>';
     console.log("Url: ");

 return fetch(url, {method: 'post'})
    .then(response => {
 return response.json();
    })
    .then((data) => {
      console.log(data);
 return data;
    });
}

Here is my page code

import {postLoyalty} from 'backend/Loyalty.jsw';
import {wixData} from 'wix-data';
import wixLocation from "wix-location";
import {myFunction} from 'public/core.js';
import wixUsers from 'wix-users';


$w.onReady(function () {
 let publickey = 'pk_live_ba43e74df464cbf521dd07ee20443ff754c3afc11adc16df2594facb2147cd76';
    myFunction(publickey)
    .then( (response) => {
        console.log(response); //your base64 encoded string
    })});

export function page1_viewportEnter(event) {
 //Add your code for this event here: 
 let email = wixUsers.currentUser.getEmail();
postLoyalty(email)
        .then(LoyaltyInfo => {
            console.log(LoyaltyInfo)
            $w("#text1").text = LoyaltyInfo.Results.Value;
        })
}

I know this is a lot but I am at my wits end on how to deal with this. Any and all feedback is greatly appreciated!

Jason Luboff
@JLuboff
Should your key be part of the url or in the header? Right now it looks like it is only part of the header
lightningudemy
@lightningudemy
@JLuboff Thank you so much for responding. I believe the key should only be put into the header and I am unsure of how to add it to the url
Btw-this is supposed to take the current user from my site and create an account for them for my external loyalty program.
@JLuboff
Jason Luboff
@JLuboff
It doesn't look like the API docs are available without signing up but it should say in the docs for making a request how to do so
lightningudemy
@lightningudemy
Well its a bit tricky because I am using Wix Corvid. The loyalty program is through Whisqr and what I need to accomplish is taking the information from my current user and adding that users email, first name and password into the api to create their loyalty member account.
alpox
@alpox
22
lightningudemy
@lightningudemy
Whats 22? @alpox
alpox
@alpox
@lightningudemy a random number which the phone in my pocket had the feeling was accurate to publish here :)
lightningudemy
@lightningudemy
Lol @alpox