Example #1
0
/**
   draw a frame, interpolating between 2 "key frames"
   @param pcnt percentage of interpolation
*/
void EWCDisplay::_drawFrame(int pcnt)
{
  int nextv;
  unsigned char h;
  unsigned char s;
  unsigned char v;

  //each row interpolates with the one before it
  for (unsigned char y = M_HEIGHT - 1; y > 0; y--) {
    for (unsigned char x = 0; x < M_WIDTH; x++) {
      h = _hueMask[y][x];
      s = 255;
      nextv =
        (((100.0 - pcnt) * _matrix[x][y]
          + _pcnt * _matrix[x][y - 1]) / 100.0)
        - _valueMask[y][x];
      v = (unsigned char)_max(0, nextv);
      _setPixel(x, y, RgbColor(HsbColor(h, s, v)));
    }
  }

  //first row interpolates with the "next" line
  for (unsigned char x = 0; x < M_WIDTH; x++) {
    h = _hueMask[0][x];
    s = 255;
    v = (unsigned char)(((100.0 - _pcnt) * _matrix[x][0] + _pcnt * _line[x]) / 100.0);

    _setPixel(x, 0, RgbColor(HsbColor(h, s, v)));
  }
}
Example #2
0
static inline RgbColor rgb_mandelbrot(const int its, const int max_iterations, const cmplx lastvector)
{
	if (its == 0 || its == max_iterations) return RgbColor(0, 0, 0);

	const double smoothed = its - log(   log(squ_abs(lastvector))/2.0 / log(max_iterations)   ) / log(2);
	const unsigned brightness = std::min(std::pow(std::max(smoothed-6, 0.0), 2), 255.0);
	HsvColor hsv(static_cast<unsigned>(its) % 256, 255, brightness);
	return RgbColor(hsv);
}
Example #3
0
Sphere::Sphere(){
    this->center_ = new Point3D(0,0,0);
    this->radius_ = 1.0;
    
    PhongShader* default_shader = new PhongShader();
    this->shader_ = default_shader;
    setDiffuseColor(RgbColor(0,0,0));
    setSpecularHighlight(RgbColor(0,0,0));
    setPhongConstant(0);
    setReflectiveColor(RgbColor(0,0,0));
    setRefractionIndex(0.0);
}
Example #4
0
 void flashgreen(uint8_t wait, uint8_t flashes) {
   uint16_t i, z;
   for (z=0; z<flashes; z++) {
     for(i=0; i<PixelCount; i++) {
       strip.SetPixelColor(i, RgbColor (0, 255, 0));
     }
     strip.Show();
     delay(wait);
     for(i=0; i<PixelCount; i++) {
       strip.SetPixelColor(i, RgbColor (0, 0, 0));
     }
     strip.Show();
     delay(wait);
   }
 }
Example #5
0
void EWCDisplay::_displayStripRandomColor()
{
  for (int i = 0; i < _stackptr; i++) {
    _leds[_ledStrip[i]] = RgbColor(HsbColor(random(0, 255), 255, 255));
  }
  _showStrip();
}
Example #6
0
 void offblack() {
     uint16_t i;
     for(i=0; i<PixelCount; i++) {
       strip.SetPixelColor(i, RgbColor (0, 0, 0));
     }
     strip.Show();
 }
void LightMatrixManager::clearDisplay()
{
  for (int i = 0; i < NUMPIXELS; i++)
  {
    _pixels.SetPixelColor(i, RgbColor(0, 0, 0));
  }
}
Example #8
0
//------------------------------------------------------------------------------
// static std::string ToRgbString(const UnsignedInt &intColor)
//------------------------------------------------------------------------------
std::string RgbColor::ToRgbString(const UnsignedInt &intColor)
{
   char buffer[20];
   RgbColor color = RgbColor(intColor);
   sprintf(buffer, "[%d %d %d]", color.Red(), color.Green(), color.Blue());
   return std::string(buffer);
}
Example #9
0
/* set the ledstrip to a certain (r, g, b) value. */
void setWS2812Strip(int r, int g, int b)
{
    for(int i = 0; i < ws2812_striplen;i++)
    {
        RgbColor color = RgbColor(r, g, b);
        strip->SetPixelColor(i, color);
    }
}
Example #10
0
RgbColor RgbColor::unserialize(JSONObject object)
{
  int new_red = atoi(JSONString::extract_string(object["red"]).c_str());
  int new_blue = atoi(JSONString::extract_string(object["blue"]).c_str());
  int new_green = atoi(JSONString::extract_string(object["green"]).c_str());

  return RgbColor(new_red, new_green, new_blue);

}
Example #11
0
//------------------------------------------------------------------------------
// void OnColorPickerChange(wxColourPickerEvent& event)
//------------------------------------------------------------------------------
void GmatColorPanel::OnColorPickerChange(wxColourPickerEvent& event)
{
   #ifdef DEBUG_COLOR_CHANGE
   MessageInterface::ShowMessage("GmatColorPanel::OnColorPickerChange() entered\n");
   #endif
   
   if (event.GetEventObject() == mOrbitColorCtrl)
   {
      wxColour wxcolor = mOrbitColorCtrl->GetColour();
      RgbColor rgbColor = RgbColor(wxcolor.Red(), wxcolor.Green(), wxcolor.Blue());
      if (mUseInputObjectColor)
      {
         mOrbitIntColor = rgbColor.GetIntColor();
      }
      else
      {
         std::string colorStr = RgbColor::ToRgbString(rgbColor.GetIntColor());
         theClonedSpacePoint->
            SetStringParameter(theClonedSpacePoint->GetParameterID("OrbitColor"), colorStr);
      }
   }
   else if (event.GetEventObject() == mTargetColorCtrl)
   {
      wxColour wxcolor = mTargetColorCtrl->GetColour();
      RgbColor rgbColor = RgbColor(wxcolor.Red(), wxcolor.Green(), wxcolor.Blue());
      if (mUseInputObjectColor)
      {
         mTargetIntColor = rgbColor.GetIntColor();
      }
      else
      {
         std::string colorStr = RgbColor::ToRgbString(rgbColor.GetIntColor());
         theClonedSpacePoint->
            SetStringParameter(theClonedSpacePoint->GetParameterID("TargetColor"), colorStr);
      }
   }
   
	mHasColorChanged = true;
	theParentGmatPanel->EnableUpdate(true);
   
   #ifdef DEBUG_COLOR_CHANGE
   MessageInterface::ShowMessage("GmatColorPanel::OnColorPickerChange() leaving\n");
   #endif
}
Example #12
0
		static RgbColor temp2color(uint16_t temp, uint8_t brightness)
		{
			uint8_t r = std::min<uint32_t>(255, temp);
			temp -= r;
			uint8_t g = std::min<uint32_t>(255, temp);
			temp -= g;
			r = (r * uint32_t(brightness) + 255) / 256;
			g = (g * uint32_t(brightness) + 255) / 512;
			temp = (temp * uint32_t(brightness) + 255) / 1024;
			return RgbColor(r, g, temp);
		}
Example #13
0
// -- NeoPixel Sunrise Functions
  void sunrise(uint16_t wait) {
    uint16_t i, j;

    for(j=0; j<256; j++) {
      for(i=0; i<PixelCount; i++) {
        strip.SetPixelColor(i, RgbColor (j, 0, 0));
      }
      strip.Show();
      delay(wait);
    }
  }
void LightMatrixManager::clearReservationsMappedToPixels()
{
    for (uint8_t week = 0; week < MAX_WEEKS; week++)
  {
    for (uint8_t day = 0; day < NUM_COLUMNS; day++)
    {
      for (uint8_t hour = 0; hour < NUM_ROWS; hour++)
      {
        _reservation[week][day][hour] = RgbColor(0,0,0);
      }
    }
  }
}
//------------------------------------------------------------------------------
// void ShowSpacePointColor(const wxString &name, UnsignedInt color = GmatColor::RED)
//------------------------------------------------------------------------------
void GroundTrackPlotPanel::ShowSpacePointColor(const wxString &name, UnsignedInt color)
{
   #ifdef DEBUG_PANEL_COLOR
   MessageInterface::ShowMessage
      ("OrbitViewPanel::ShowSpacePointColor() name='%s'\n", name.c_str());
   #endif
   
   if (!name.IsSameAs(""))
   {
      std::string selObjName = name.c_str();
      
      // if object name not found, insert
      if (mOrbitColorMap.find(selObjName) == mOrbitColorMap.end())
      {
         #ifdef DEBUG_PANEL_COLOR
         MessageInterface::ShowMessage
            ("ShowSpacePointColor() name not found, so adding it to color map\n");
         #endif
         
         mOrbitColorMap[selObjName] = RgbColor(color);
         mTargetColorMap[selObjName] = RgbColor(GmatColor::ORANGE);
      }
      
      RgbColor orbColor = mOrbitColorMap[selObjName];
      RgbColor targColor = mTargetColorMap[selObjName];
      
      #ifdef DEBUG_PANEL_COLOR
      MessageInterface::ShowMessage
         ("OrbitViewPanel::ShowSpacePointColor() orbColor=%u, targColor=%u\n",
          orbColor.GetIntColor(), targColor.GetIntColor());
      #endif
      
      mOrbitColor.Set(orbColor.Red(), orbColor.Green(), orbColor.Blue());      
      mTargetColor.Set(targColor.Red(), targColor.Green(), targColor.Blue());
      
      mOrbitColorCtrl->SetColour(mOrbitColor);
      mTargetColorCtrl->SetColour(mTargetColor);
   }
}
Example #16
0
RgbColor JpegMap::blurPixel(const unsigned x, const unsigned y) const
{
	unsigned r = 0, g = 0, b = 0;
	unsigned cnt = 4;

	addPixelRgbValues(getPixel(x, y), r, g, b, cnt);

	if (x > 0        ) { addPixelRgbValues(getPixel(x-1, y  ), r, g, b); ++cnt; }
	if (x < _width-1 ) { addPixelRgbValues(getPixel(x+1, y  ), r, g, b); ++cnt; }
	if (y > 0        ) { addPixelRgbValues(getPixel(x  , y-1), r, g, b); ++cnt; }
	if (y < _height-1) { addPixelRgbValues(getPixel(x  , y+1), r, g, b); ++cnt; }

	return RgbColor(r / cnt, g / cnt, b / cnt);
}
Example #17
0
void loop() {
  ArduinoOTA.handle();

  // -- MQTT connect
    if (!client.connected()) {
      error_path += thisDevicePath;
      error_path += "/";
      error_path += "errors/";
      error_path += thisDeviceName;
      if (client.connect(MQTT::Connect(thisDeviceName).set_will(error_path, "disconnected"))) {
        Serial.println("MQTT connected");
        client.set_callback(callback);
        client.subscribe(MQTT::Subscribe()
          .add_topic("/deviceInfo/#")
          .add_topic("/global/#")
          .add_topic(subscribe_path)
                 );
        // notify persistence of device IP
          String persistence_ip_path = "/persistence/control/";
          persistence_ip_path += thisDeviceName;
          persistence_ip_path += "/ip";
          client.publish(MQTT::Publish(persistence_ip_path, local_ip_str).set_qos(2));

        // ask persistence/control/device_name/chipID "request states" --  do you have any states with my device_name or chipID
          String persistence_path = "/persistence/control/";
          persistence_path += thisDeviceName;
          persistence_path += "/";
          persistence_path += chip_id;
          client.publish(MQTT::Publish(persistence_path, "request states").set_qos(2));
          Serial.println("request states sent");
      }
    }

    if (client.connected()) {
      client.loop();
    }


  // -- NeoPixel continuous update
    for(int i=0; i<PixelCount; i++) {
      strip.SetPixelColor(i, RgbColor (redValue, greenValue, blueValue));
    }
    strip.Show();


  yield();
}
RgbColor getMirektoRGB(int mirek) {
  int hectemp = 10000 / mirek;
  int r, g, b;
  if (hectemp <= 66) {
    r = COLOR_SATURATION;
    g = 99.4708025861 * log(hectemp) - 161.1195681661;
    b = hectemp <= 19 ? 0 : (138.5177312231 * log(hectemp - 10) - 305.0447927307);
  } else {
    r = 329.698727446 * pow(hectemp - 60, -0.1332047592);
    g = 288.1221695283 * pow(hectemp - 60, -0.0755148492);
    b = COLOR_SATURATION;
  }
  r = r > COLOR_SATURATION ? COLOR_SATURATION : r;
  g = g > COLOR_SATURATION ? COLOR_SATURATION : g;
  b = b > COLOR_SATURATION ? COLOR_SATURATION : b;
  return RgbColor(r, g, b);
}
Example #19
0
RgbColor RgbColor::BilinearBlend(const RgbColor& c00,
                                 const RgbColor& c01,
                                 const RgbColor& c10,
                                 const RgbColor& c11,
                                 float x,
                                 float y)
{
    float v00 = (1.0f - x) * (1.0f - y);
    float v10 = x * (1.0f - y);
    float v01 = (1.0f - x) * y;
    float v11 = x * y;

    return RgbColor(
               c00.R * v00 + c10.R * v10 + c01.R * v01 + c11.R * v11,
               c00.G * v00 + c10.G * v10 + c01.G * v01 + c11.G * v11,
               c00.B * v00 + c10.B * v10 + c01.B * v01 + c11.B * v11);
}
RgbColor getXYtoRGB(float x, float y, int brightness_raw) {
  float brightness = ((float)brightness_raw) / 255.0f;
  float bright_y = brightness / y;
  float X = x * bright_y;
  float Z = (1 - x - y) * bright_y;

  // convert to RGB (0.0-1.0) color space
  float R = X * 1.4628067 - brightness * 0.1840623 - Z * 0.2743606;
  float G = -X * 0.5217933 + brightness * 1.4472381 + Z * 0.0677227;
  float B = X * 0.0349342 - brightness * 0.0968930 + Z * 1.2884099;

  // apply inverse 2.2 gamma
  float inv_gamma = 1.0 / 2.4;
  float linear_delta = 0.055;
  float linear_interval = 1 + linear_delta;
  float r = R <= 0.0031308 ? 12.92 * R : (linear_interval) * pow(R, inv_gamma) - linear_delta;
  float g = G <= 0.0031308 ? 12.92 * G : (linear_interval) * pow(G, inv_gamma) - linear_delta;
  float b = B <= 0.0031308 ? 12.92 * B : (linear_interval) * pow(B, inv_gamma) - linear_delta;

  return RgbColor(r * COLOR_SATURATION,
                  g * COLOR_SATURATION,
                  b * COLOR_SATURATION);
}
Example #21
0
//------------------------------------------------------------------------------
// void OnCheckBoxChange(wxCommandEvent& event)
//------------------------------------------------------------------------------
void GmatColorPanel::OnCheckBoxChange(wxCommandEvent& event)
{
   mHasOverrideColorChanged = true;
   mOverrideOrbitColor = mOverrideOrbitColorCheckBox->GetValue();
   
   if (mOverrideOrbitColor)
   {
      mOrbitColorLabel->Enable(true);
      mOrbitColorCtrl->Enable(true);      
   }
   else
   {
      // Show original orbit color
      RgbColor rgbOrbitColor = RgbColor(mDefaultOrbitColor);
      mOrbitColor.Set(rgbOrbitColor.Red(), rgbOrbitColor.Green(), rgbOrbitColor.Blue());      
      mOrbitColorCtrl->SetColour(mOrbitColor);
      mOrbitIntColor = rgbOrbitColor.GetIntColor();
      mOrbitColorLabel->Enable(false);
      mOrbitColorCtrl->Enable(false);
   }
   
	theParentGmatPanel->EnableUpdate(true);
}
Example #22
0
/* 
    fade all the pixels individually from one color to the next.
    creating a rainbow like effect.
*/
void rainbowWS2812(int speed, int brightness)
{
    cinterval = speed + 1;
    ccurrent = millis();
    if((ccurrent - cprevious) >= cinterval)
    {
        cprevious = ccurrent;
        static int range = 0xff*3;
        uint8_t buffer[3][ws2812_striplen];
        int i, s;
        colors = colorinc();
        for(i = 0; i < ws2812_striplen; i++)
        {
            for(s = 0; s < range/ws2812_striplen; s++)
                colors = colorinc();
            float brightnessFactor = (float)(((float)brightness) / 100);
            int r = colors[RED] * brightnessFactor;
            int g = colors[GREEN] * brightnessFactor;
            int b = colors[BLUE] * brightnessFactor;
            RgbColor rgbcolor = RgbColor(r, g, b);
            strip->SetPixelColor(i, rgbcolor);
        }
    }
}
Example #23
0
RgbColor RgbColor::LinearBlend(RgbColor left, RgbColor right, float progress)
{
	return RgbColor( left.R + ((right.R - left.R) * progress),
		left.G + ((right.G - left.G) * progress),
		left.B + ((right.B - left.B) * progress));
}
Example #24
0
RgbColor JpegMap::getPixel(const unsigned x, const unsigned y) const
{
	const unsigned offset = ( x + y * _width ) * _bpp;
	if (x >= _width || y >= _height) return RgbColor(0, 0, 0);
	return RgbColor(_raw[offset], _raw[offset+1], _raw[offset+2]);
}
Example #25
0
//------------------------------------------------------------------------------
UnsignedInt RgbColor::ToIntColor(const std::string &colorString)
{
   #ifdef DEBUG_INT_COLOR
   MessageInterface::ShowMessage
      ("RgbColor::ToIntColor() entered, colorString = '%s'\n", colorString.c_str());
   #endif
   
   // First figure out if input is a color name
   ColorDatabase *colorDb = ColorDatabase::Instance();
   UnsignedInt intColor;
   
   if (!GmatStringUtil::StartsWith(colorString, "[") &&
       !GmatStringUtil::EndsWith(colorString, "]"))
   {
      if (colorDb->HasColor(colorString))
      {
         intColor = colorDb->GetIntColor(colorString);
         #ifdef DEBUG_INT_COLOR
         MessageInterface::ShowMessage("RgbColor::ToIntColor() returning %06X\n", intColor);
         #endif
         return intColor;
      }
      else
      {
         UtilityException ue;
         ue.SetDetails("The color \"%s\" not found in the color database. "
                       "Available colors are \"%s\"", colorString.c_str(),
                       colorDb->GetAllColorNames().c_str());
         throw ue;
      }
   }
   
   // It is rgb tuples
   UnsignedIntArray intArray = GmatStringUtil::ToUnsignedIntArray(colorString);
   Byte rgb[3];
   bool error = false;
   if (intArray.size() != 3)
   {
      error = true;
   }
   else
   {
      for (UnsignedInt i = 0; i < intArray.size(); i++)
      {
         if (intArray[i] < 0 || intArray[i] > 255)
         {
            error = true;
            break;
         }
         else
         {
            rgb[i] = intArray[i];
         }
      }
   }
   
   if (error)
   {
      UtilityException ue;
      ue.SetDetails("\"%s\" has invalid RGB color values. Valid color value is "
                    "triplet Integer number between 0 and 255 inside of [ ]",
                    colorString.c_str());
      throw ue;
   }
   else
   {
      RgbColor color = RgbColor(rgb[0], rgb[1], rgb[2]);
      intColor = color.GetIntColor();
      #ifdef DEBUG_INT_COLOR
      MessageInterface::ShowMessage("RgbColor::ToIntColor() returning %06X\n", intColor);
      #endif
      return intColor;
   }
}
Example #26
0
AmbientLight::AmbientLight() {
    this->color_ = RgbColor(0,0,0);
}
DirectionalLight::DirectionalLight(){
    this->color_ = RgbColor(0,0,0);
    this->direction_from_light_ = new Vector3D(0,0,0);
}
Example #28
0
//------------------------------------------------------------------------------
// void LoadData()
//------------------------------------------------------------------------------
void GmatColorPanel::LoadData()
{
   #ifdef DEBUG_PANEL_LOAD
   MessageInterface::ShowMessage("GmatColorPanel::LoadData() entered.\n");
   #endif

   try
   {
      if (mUseInputObjectColor)
      {
         // Load colors from the input object name
         SpacePoint *sp = (SpacePoint*)
            ((theParentGmatPanel->GetGuiInterpreter())->GetConfiguredObject(mSpacePointName));
         if (sp)
         {
            mOrbitIntColor = sp->GetCurrentOrbitColor();
            mTargetIntColor = sp->GetCurrentTargetColor();
         }
      }
      else
      {
         // Load colors from the spacecraft
         mOrbitIntColor = theClonedSpacePoint->GetCurrentOrbitColor();
         mTargetIntColor = theClonedSpacePoint->GetCurrentTargetColor();
      }
      
      mDefaultOrbitColor = mOrbitIntColor;
      if (mOverrideOrbitColor)
         mOrbitIntColor = mOverrdingColor;
      
      RgbColor rgbOrbitColor = RgbColor(mOrbitIntColor);
      RgbColor rgbTargetColor = RgbColor(mTargetIntColor);
      
      #ifdef DEBUG_PANEL_LOAD
      MessageInterface::ShowMessage("   rgbOrbitColor  = %06X\n", rgbOrbitColor.GetIntColor());
      MessageInterface::ShowMessage("   rgbTargetColor = %06X\n", rgbTargetColor.GetIntColor());
      #endif
      
      mOrbitColor.Set(rgbOrbitColor.Red(), rgbOrbitColor.Green(), rgbOrbitColor.Blue());      
      mOrbitColorCtrl->SetColour(mOrbitColor);
      mTargetColor.Set(rgbTargetColor.Red(), rgbTargetColor.Green(), rgbTargetColor.Blue());
      mTargetColorCtrl->SetColour(mTargetColor);
      
      // If showing only orbit color, hide target color
      if (mShowOrbitColorOnly)
      {
         mTargetColorLabel->Hide();
         mTargetColorCtrl->Hide();
      }
      
      // Set value to overrding color CheckBox
      if (mOverrideOrbitColor)
         mOverrideOrbitColorCheckBox->SetValue(true);
      else
         mOverrideOrbitColorCheckBox->SetValue(false);
      
      // If not showing override color check box, hide it
      if (!mShowOverrideOrbitColorCheckBox)
         mOverrideOrbitColorCheckBox->Hide();
      else
      {
         // If not overriding orbit color, disable it
         if (!mOverrideOrbitColor)
         {
            mOrbitColorLabel->Disable();
            mOrbitColorCtrl->Disable();
         }
      }
      Layout();
   }
   catch (BaseException &e)
   {
      MessageInterface::PopupMessage(Gmat::ERROR_, e.GetFullMessage().c_str());
   }
   
   #ifdef DEBUG_PANEL_LOAD
   MessageInterface::ShowMessage("GmatColorPanel::LoadData() leaving\n");
   #endif
}
Example #29
0
void loop() {
  ArduinoOTA.handle();

  // -- MQTT connect
    if (!client.connected()) {
      error_path += thisDevicePath;
      error_path += "/";
      error_path += "errors/";
      error_path += thisDeviceName;
      if (client.connect(MQTT::Connect(thisDeviceName).set_will(error_path, "disconnected"))) {
        Serial.println("MQTT connected");
        client.set_callback(callback);
        client.subscribe(MQTT::Subscribe()
          .add_topic("/deviceInfo/#")
          .add_topic("/global/#")
          .add_topic(subscribe_path)
                 );
        // notify persistence of device IP
          String persistence_ip_path = "/persistence/control/";
          persistence_ip_path += thisDeviceName;
          persistence_ip_path += "/ip";
          client.publish(MQTT::Publish(persistence_ip_path, local_ip_str).set_qos(2));

        // ask persistence/control/device_name/chipID "request states" --  do you have any states with my device_name or chipID
          String persistence_path = "/persistence/control/";
          persistence_path += thisDeviceName;
          persistence_path += "/";
          persistence_path += chip_id;
          client.publish(MQTT::Publish(persistence_path, "request states").set_qos(2));
          Serial.println("request states sent");
      }
    }

    if (client.connected()) {
      client.loop();
    }

  /*
  // -- Device Request Response
    if (sendJSON) {
      buildDeviceJson(); // flag set to false inside function
    }
  */

  /*
  // -- Confirm Messages
    if (sendConfirm) {
      client.publish(MQTT::Publish(confirmPath, confirmPayload).set_qos(2));
      sendConfirm = false;
    }
  */

  /*
  // -- NeoPixel updates
    if (neoPixelChange) {
      for(int i=0; i<PixelCount; i++) {
        strip.SetPixelColor(i, RgbColor (redValue, greenValue, blueValue));
      }
      strip.Show();
      neoPixelChange = false;
    }
  */

  // -- NeoPixel continuous update
    for(int i=0; i<PixelCount; i++) {
      strip.SetPixelColor(i, RgbColor (redValue, greenValue, blueValue));
    }
    strip.Show();

  /*
  // -- NeoPixel Sunrise Alarm Code
    if (millis() - lastcheck > alarmcheck)  {
      DateTime now = RTC.now();
      lastcheck = millis();
      if (alarmminute == now.minute() && alarmhour == now.hour()) {
         sunrise(4000);
         sunrise(400);
         sunrise(40);
         sunrise(40);
         sunrise(40);
         sunrise(40);
         sunrise(40);
         sunrise(20);
         sunrise(20);
         black();
      }
    }
  */


  // Do things every NTPLimit seconds
  if ( millis() - tick > NTPlimit) {
    tick = millis();

    /*
    // -- get server and send NTP packet
      //get a random server from the pool
      WiFi.hostByName(ntpServerName, timeServerIP);

      sendNTPpacket(timeServerIP); // send an NTP packet to a time server
      // wait to see if a reply is available
      delay(1000);

      int cb = udp.parsePacket();
      if (!cb) {
        Serial.println("no packet yet");
      }
      else {
        //Serial.print("packet received, length=");
        //Serial.println(cb);
        udp.read(packetBuffer, NTP_PACKET_SIZE); // read the packet into the buffer

        unsigned long highWord = word(packetBuffer[40], packetBuffer[41]);
        unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]);
        // combine the four bytes (two words) into a long integer
        // this is NTP time (seconds since Jan 1 1900):
        unsigned long secsSince1900 = highWord << 16 | lowWord;
        const unsigned long seventyYears = 2208988800UL;
        unsigned long epoch = secsSince1900 - seventyYears;

        int UTChour = (epoch  % 86400L) / 3600;   // (86400 equals secs per day)
        int UTCmin = (epoch  % 3600) / 60;        // (3600 equals secs per minute)
        //Serial.println(UTChour);

        Serial.print(year(epoch));
        Serial.print('-');
        Serial.print(month(epoch));
        Serial.print('-');
        Serial.println(day(epoch));

        Serial.print("The UTC time is ");       // UTC is the time at Greenwich Meridian (GMT)
        Serial.print(UTChour);
        Serial.print(':');
        if ( ((epoch % 3600) / 60) < 10 ) {
          Serial.print('0');
        }
        Serial.print(UTCmin);
        Serial.print(':');
        if ( (epoch % 60) < 10 ) {
          Serial.print('0');
        }
        Serial.println(epoch % 60); // print the second
      }
    */

    /*
    // -- begin neropixel test

      delay(1000);

      Serial.println("Colors R, G, B, W...");

      // set the colors,
      // if they don't match in order, you need to use NeoGrbFeature feature
      strip.SetPixelColor(0, RgbColor (128, 0, 0));
      strip.SetPixelColor(1, green);
      strip.SetPixelColor(2, blue);
      strip.SetPixelColor(3, white);
      // the following line demonstrates rgbw color support
      // if the NeoPixels are rgbw types the following line will compile
      // if the NeoPixels are anything else, the following line will give an error
      //strip.SetPixelColor(3, RgbwColor(colorSaturation));
      strip.Show();


      delay(1000);

      Serial.println("Off ...");

      // turn off the pixels
      strip.SetPixelColor(0, black);
      strip.SetPixelColor(1, black);
      strip.SetPixelColor(2, black);
      strip.SetPixelColor(3, black);
      strip.Show();

      delay(1000);

      Serial.println("HSL Colors R, G, B, W...");

      // set the colors,
      // if they don't match in order, you may need to use NeoGrbFeature feature
      strip.SetPixelColor(0, hslRed);
      strip.SetPixelColor(1, hslGreen);
      strip.SetPixelColor(2, hslBlue);
      strip.SetPixelColor(3, hslWhite);
      strip.Show();


      delay(1000);

      Serial.println("Off again...");

      // turn off the pixels
      strip.SetPixelColor(0, hslBlack);
      strip.SetPixelColor(1, hslBlack);
      strip.SetPixelColor(2, hslBlack);
      strip.SetPixelColor(3, hslBlack);
      strip.Show();
    */

    // -- neopixel sunrise test
      //sunrise(40);
      //offblack();

    /*
    // -- print IP address
      Serial.println(WiFi.localIP());
      //Serial.println("..");
    */
  }


  yield();
}
Example #30
0
int EWCDisplay::_stackptr = 0;
uint8_t EWCDisplay::_testHours = 0;
uint8_t EWCDisplay::_testMinutes = 0;
#if FEATURE_WEATHER()
int8_t EWCDisplay::_testTemperature = -39;
uint8_t EWCDisplay::_testWeather = 0;
#endif
uint8_t EWCDisplay::_testLED = 0;
uint8_t EWCDisplay::_languageMode = RHEIN_RUHR_MODE;
boolean EWCDisplay::_autoBrightness = false;

NeoPixelBus<NeoRgbFeature, NeoEsp8266BitBang800KbpsMethod> _ledBus(NUM_LEDS, STRIP_DATA_PIN);
NeoPixelAnimator _animations(1);

RgbColor EWCDisplay::_leds[NUM_LEDS];
RgbColor EWCDisplay::_red = RgbColor(128, 0, 0);
RgbColor EWCDisplay::_green = RgbColor(0, 128, 0);
RgbColor EWCDisplay::_blue = RgbColor(0, 0, 128);
RgbColor EWCDisplay::_white = RgbColor(128);
RgbColor EWCDisplay::_black = RgbColor(0);
RgbColor EWCDisplay::_defaultColor = _white;
typedef void (*FunctPtr)();
FunctPtr EWCDisplay::_currentDisplay;

// for the fire from https://github.com/giladaya/arduino-led-matrix/blob/master/fire/fire.ino
// these values are substracetd from the generated values to give a shape to the animation
uint8_t EWCDisplay::_valueMask[M_HEIGHT][M_WIDTH] = {
  {32 , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 32 , 32 , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 32 },
  {48 , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 48 , 48 , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 48 },
  {64 , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 48 , 48 , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 64 },
  {96 , 32 , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 32 , 64 , 64 , 32 , 0  , 0  , 0  , 0  , 0  , 0  , 0  , 32 , 96 },