Review – Raspberry Pi 7 inch HDMI HD 1024 * 600 Touch Screen

This is a review for this product from Banggood: Raspberry Pi 7 inch HDMI HD 1024 * 600 Touch Screen Module Kit With Housing Bracket

This is a great screen and stand overall, I’m pleased with the final results, it works great with my Raspberry Pi 3 as a fancy alarm clock.
Now the big hassle was putting it all together and setting it all up. That took me a long time due to the fact there’s no documentation for putting together the mount neither for the lcd driver parts.
I’ve attached some pictures of mine in case this helps people building theirs.
Packaging was fine, a little “light” for shipping a screen but… I didn’t notice anything broken yet.

Some things I noticed and thought I’d share, this may be useful to future buyers:
– The touchscreen driver ribbon (small one) can be put in any direction, this will just swap X and Y on the touchscreen, if that is the case, just invert the ribbon again. No damage done.
– Also that touchscreen driver ribbon needs to be placed properly into the other connector. The connector is a bit too big and so the ribbon can be placed too much to the left/right, make sure it’s centered! Otherwise you’ll get no touch input.
– For me, the Raspberry Pi 3 (debian jessie) needed to be upgraded using “rpi-update” to get the proper drivers for the touchscreen to work and wifi too (yes, odd…)
– For those not familiar with hooking up a screen ribbon, the connector for the main ribbon has 2 little latches on each side that need to be pulled out a bit before putting the ribbon in, then push them back in.
– The screen just lays on the stand, it can easily be knocked out of place, by your cat, your kid, your wife or your servant. Personally I put some Velcro horizontally at the top to keep it stable. It is pretty steady now and can be removed easily.
– The touchscreen sensor is actually 5-10 pixels smaller than the screen itself, so yeah you can’t touch corners…. : (
– The touchscreen is resistive, so only one finger is detected, and it can feel “weird” or hard to touch properly if you’re used to capacitive (newer) touchscreens. Though with a stylus it works quite well.
– No need to install the given drivers for the touchscreen driver on the latest Debian Jessie, just make sure your ribbon is properly placed in the middle of the plug (see my other comment), and that you ran xinput_calibrator properly (https://github.com/tias/xinput_calibrator) and saved your settings into /etc/X11/xorg.conf.d/99-calibration.conf.
– The screen itself can be used with pretty much any device (as long as it can do vga, hdmi or composite video) you won’t get the touchscreen part but it can be nice to have that option.
– There’s no dedicated spot to place a Raspberry Pi, but there’s a bit of room in the back so I may stick it in there.
– Screen image quality is a little on the blurry side, but I was expecting that. At a distance it’s fine, but being a techie I’d hate to use that as a tablet. There’s some sharpness settings, but that doesn’t change much. Color temperature is fine by default. Not too blue/yellow.
– Screen back is a little dirty/stained. It’s quite barebone and not ready for a typical end-user. For geeks its fine.

Overall I’d say it’s pretty good for the price, the stand is nice and sturdy.

IMG_-1178169905

IMG_20160416_161022_c

IMG_20160416_161000

IMG_20160416_160941

IMG_20160416_160359

How to add a Password reset link on user login block in Drupal

In Drupal 7, adding a link to allow users to reset their password (a “forgot my password” link) is quite easy through the hook_form_alter() hook.

/**
 * implements hook_form_alter().
 */
function mythemename_form_alter(&$form, &$form_state, $form_id)
{
  switch($form_id)
  {
    case 'user_login':
    case 'user_login_block':
      $form['links'] = array(
        array('#markup' => 'Forgot your password?'),
        '#weight' => 100,
      );
      break;
  }
}

Temperature Display with DHT22, VirtualWire and a LCD Shield on an Arduino Uno

The code below displays the temperature and humidity from a DHT22, but also receives that same data from another arduino or atmega through an RF Link using VirtualWire and displays it as well.

VirtualWire can be downloaded from:
airspayce.com/mikem/arduino/VirtualWire/index.html
DHT22 Library from Adafruit: github.com/adafruit/DHT-sensor-library
LCD Library and DFR Key from Linksprite: Linksprite Wiki

// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain

#include "DHT.h"
#include 
#include "DFR_Key.h"
#include 

// PIN 11 = RX
#define DHTPIN 12     // what pin we're connected to
#define LCD_BACKLIGHT_PIN         10  // D10 controls LCD backlight
//some example macros with friendly labels for LCD backlight/pin control, tested and can be swapped into the example code as you like
#define LCD_BACKLIGHT_OFF()     digitalWrite( LCD_BACKLIGHT_PIN, LOW )
#define LCD_BACKLIGHT_ON()      digitalWrite( LCD_BACKLIGHT_PIN, HIGH )
#define LCD_BACKLIGHT(state)    { if( state ){digitalWrite( LCD_BACKLIGHT_PIN, HIGH );}else{digitalWrite( LCD_BACKLIGHT_PIN, LOW );} }

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11   // DHT 11 
#define DHTTYPE DHT22   // DHT 22  (AM2302)
//#define DHTTYPE DHT21   // DHT 21 (AM2301)


LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 );
DFR_Key keypad;

DHT dht(DHTPIN, DHTTYPE);

int localKey = 0;
boolean displaycelsius = false;
boolean isstart = true;
boolean backlight = true;
boolean displayold = false;
float oldt = 0;
float oldh = 0;
float mint = 0;
float minh = 0;
float maxt = 0;
float maxh = 0;
float remt = 0;
float remh = 0;
float rempI = 0;
float rempM = 0;
float remt2 = 0;

float oldcelsius = false;
unsigned long previousMillis = 0;
long interval = 5000;
float h = 0;
float t = 0;
int displaymode = 4;

byte smiley[8] = {
  0b00000,
  0b00000,
  0b01010,
  0b00000,
  0b00000,
  0b10001,
  0b01110,
  0b00000
};

byte frownie[8] = {
  0b00000,
  0b00000,
  0b01010,
  0b00000,
  0b00000,
  0b00000,
  0b01110,
  0b10001
};


void setup() {
  Serial.begin(9600);
  
  // set up Receiver (first because it may set unused pins to wrong mode)
  vw_setup(2000);	 // Bits per sec
  vw_rx_start();       // Start the receiver PLL running


  // set up LCD  
  lcd.begin(16, 2);
  //Serial.println("DHTxx test!");
  lcd.print("Getting Temp!");
  dht.begin();
  keypad.setRate(10);
  
  digitalWrite( LCD_BACKLIGHT_PIN, HIGH );  //backlight control pin D3 is high (on)
  pinMode( LCD_BACKLIGHT_PIN, OUTPUT );     //D3 is an output
  
  // create a new character
  lcd.createChar(1, smiley);
  // create a new character
  lcd.createChar(2, frownie);

  LCD_BACKLIGHT(backlight);


}

void loop() {

  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;

  
  localKey = keypad.getKey();
  if (localKey == LEFT_KEY)
  {
    lcd.clear();
    displaymode = (displaymode + 1) % 6;
  }
  if (localKey == UP_KEY)
  {
    lcd.clear();
    //displayold = !displayold;
  }
  if (localKey == RIGHT_KEY)
  {
    backlight = !backlight;
    LCD_BACKLIGHT(backlight);
  }
  
  unsigned long currentMillis = millis();
  
  if(isstart || (currentMillis - previousMillis > interval)) {
    previousMillis = currentMillis;   
  
    // Reading temperature or humidity takes about 250 milliseconds!
    // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
    h = dht.readHumidity();
    t = dht.readTemperature(!displaycelsius);
    /*LCD_BACKLIGHT_OFF();
    delay(200);
    LCD_BACKLIGHT_ON();*/
  }
  
  if(isstart || localKey == SELECT_KEY)
  {
    isstart = false;
    oldh = h;
    oldt = t;
    minh = h;
    mint = t;
    maxh = h;
    maxt = t;
    if(backlight)
    {
      LCD_BACKLIGHT_OFF();
      delay(200);
      LCD_BACKLIGHT_ON();
    }
  }
  
  minh = min(minh, h);
  mint = min(mint, t);
  maxh = max(maxh, h);
  maxt = max(maxt, t);

  lcd.setCursor( 0, 0 );
  // check if returns are valid, if they are NaN (not a number) then something went wrong!
  if (isnan(t) || isnan(h)) {
    //Serial.println("Failed to read from DHT");
    lcd.print("Sensor Error       ");
    lcd.setCursor( 0, 1 );
    lcd.print("                ");
  } else {
    if(displaymode == 0)
    {
      lcd.setCursor( 0, 0 );
      lcd.print("Temp.:  ");
      lcd.print(t,1);// Serial.print(t);
      lcd.print("F ");
      if((int)t>=68)
        lcd.write(1);
      else
        lcd.write(2);
      
      lcd.setCursor( 0, 1 );
      lcd.print("Humid.: ");
      lcd.print(h,1);// Serial.print(h);
      lcd.print("%");// Serial.print(" %\t");
    }
    
    if(displaymode == 1) // show saved temps
    {
      lcd.setCursor( 0, 0 );
      lcd.print("T: ");
      lcd.print(t,1);// Serial.print(t);
      lcd.print("F (");
      lcd.print(oldt,1);// Serial.print(h);
      lcd.print("F)");// Serial.print(" %\t");
      
      lcd.setCursor( 0, 1 );
      lcd.print("H: ");
      lcd.print(h,1);// Serial.print(h);
      lcd.print("% (");
      lcd.print(oldh,1);// Serial.print(h);
      lcd.print("%)");// Serial.print(" %\t");    
    }
    
    if(displaymode == 2) // show min/max temps
    {
      lcd.setCursor( 0, 0 );
      lcd.print("Max T: ");
      lcd.print(maxt,1);// Serial.print(t);
      lcd.print("F");
      
      lcd.setCursor( 0, 1 );
      lcd.print("Min T: ");
      lcd.print(mint,1);// Serial.print(t);
      lcd.print("F");
    }
    
    if(displaymode == 3) // show min/max humid
    {
      lcd.setCursor( 0, 0 );
      lcd.print("Max H: ");
      lcd.print(maxh,1);// Serial.print(h);
      lcd.print("%");
      
      lcd.setCursor( 0, 1 );
      lcd.print("Min H: ");
      lcd.print(minh,1);// Serial.print(h);
      lcd.print("%");
    }
    
    if(displaymode == 4) // show local and remote
    {
      lcd.setCursor( 0, 0 );
      lcd.print("LT:");
      lcd.print(t,1);// Serial.print(t);
      lcd.print(" LH:");
      lcd.print(h,1);// Serial.print(h);
      //lcd.print("F");// Serial.print(" %\t");
      
      lcd.setCursor( 0, 1 );
      lcd.print("RT:");
      lcd.print(remt,1);// Serial.print(h);
      lcd.print(" RH:");
      lcd.print(remh,1);// Serial.print(h);
      //lcd.print("");// Serial.print(" %\t");    
    }

    if(displaymode == 5) // show Remote
    {
      lcd.setCursor( 0, 0 );
      lcd.print("P:");
      lcd.print(rempI,1);// Serial.print(t);
      lcd.print("in ");
      lcd.print(rempM,1);// Serial.print(h);
      lcd.print("m");
      //lcd.print("F");// Serial.print(" %\t");
      
      lcd.setCursor( 0, 1 );
      lcd.print("T: ");
      lcd.print(remt,1);// Serial.print(h);
      lcd.print(" (");
      lcd.print(remt2,1);// Serial.print(h);
      lcd.print(")");
      //lcd.print("");// Serial.print(" %\t");    
    }
    
    /*if(!animfirst || localKey == SELECT_KEY)
    {
      animfirst = true;
      for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
        // scroll one position left:
        lcd.scrollDisplayRight(); 
        // wait a bit:
        //delay(150);
      }
    
      // scroll 29 positions (string length + display length) to the right
      // to move it offscreen right:
      for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
        // scroll one position right:
        lcd.scrollDisplayLeft(); 
        // wait a bit:
        delay(50);
      }
    }*/

    
  }


    if (vw_get_message(buf, &buflen)) // Non-blocking
    {
	int i;

        digitalWrite(13, true); // Flash a light to show received good message
	// Message with a good checksum received, dump it.
	Serial.print("Got: ");
	
	for (i = 0; i < buflen; i++)
	{
	    Serial.print(buf[i], DEC);
	    Serial.print(" ");
	}
	Serial.println("");
        digitalWrite(13, false);
        
        if(buf[0] == 200)
        {
          remh = (float) buf[1] + ((float) buf[2]) / 100.0;
          remt = (float) buf[3] + ((float) buf[4]) / 100.0;
          rempI = (float) buf[6] + ((float) buf[7]) / 100.0;
          rempM = 100.0 * (float) buf[8] + (float) buf[9] + ((float) buf[10]) / 100.0;
          remt2 = (float) buf[11] + ((float) buf[12]) / 100.0;
        }
    }

  if(localKey != SAMPLE_WAIT)
    delay(200); // delay to avoid key getting registered multiple times.
}

How to install a rtl8192cu on the Beaglebone Black (BBB) running Angstrom

opkg update
opkg upgrade
opkg install kernel-dev
opkg install kernel-headers

You may need to reboot.

cd /usr/src/kernel
make scripts
ln -s /usr/src/kernel /lib/modules/$(uname -r)/build
cd ~
git clone git://github.com/cmicali/rtl8192cu_beaglebone.git
cd rtl8192cu_beaglebone
make CROSS_COMPILE=""

Then follow 2.2 from bonenotes.tumblr.com:

Install the driver

mv 8192cu.ko /lib/modules/$(uname -r)
depmod -a
cd /etc/modules-load.d
echo "8192cu" > rtl8192cu-vendor.conf

Blacklist the old rtlwifi drivers

cd /etc/modprobe.d
echo "install rtl8192cu /bin/false" >wifi_blacklist.conf
echo "install rtl8192c_common /bin/false" >>wifi_blacklist.conf
echo "install rtlwifi /bin/false" >>wifi_blacklist.conf

Edit /var/lib/connman/settings and enable WIFI

[global]
OfflineMode=false

[Wired]
Enable=true
Tethering=false

[WiFi]
Enable=true
Tethering=false

Encrypt your passphrase

wpa_passphrase YourSSID YourPassphrase

Edit /var/lib/connman/wifi.config and set it to the following

[service_home]
Type=wifi
Name=YourSSID
Passphrase=YourEncryptedPassphrase

Plug in your WIFI adaptor and reboot

shutdown -r 0

Sources & Thanks:
Big Thanks to cmicali: bonenotes.tumblr.com/
Thanks to Nomel: nomel.org/post/30357133735/beaglebone-tutorial-how-to-compile-kernel-modules-and

CSS3 box-shadow on left and right sides only

It is possible to have inset shadows on both left and right sides of a block. It is a matter of showing only one side of the box-shadow at a time, and so you need two box-shadows (one for each side of the block you wish to have shadows, and we can put both CSS codes in the same property).

Here is an example that should be compatible with Firefox, Chrome and Opera.

box {
    -moz-box-shadow:
        inset 5px 0 5px -5px #333,
        inset -5px 0 5px -5px #333;
    -webkit-box-shadow:
        inset 5px 0 5px -5px #333,
        inset -5px 0 5px -5px #333;
    box-shadow:
        inset 5px 0 5px -5px #333,
        inset -5px 0 5px -5px #333;
}

Here is the result:

Lorem ipsum…

Inspired from Playing with CSS3 box shadow [demente-design.com]

fetchyahoo 2.14.0 deb package for Ubuntu 10.10 Maverick

On Nov. 16th, fetchyahoo 2.14.0 was released, and I did not find any deb package available for it on the Launchpad PPA’s. And I used to package it before, so it took me not very long to update the package to the newest version.

Fetchyahoo is a script written in Perl which fetches your email from Yahoo! Mail and either saves it in your mbox or can also send it to an IMAP folder. It pulls email using the web interface which is very useful for those with Yahoo Mail who do not have POP3 or IMAP access, since POP3 access for Yahoo Mail seems to be a paid service.

The deb package for fetchyahoo 2.14.0 is available from my PPA. You can either add it to your sources.list:

sudo add-apt-repository ppa:weboide

or you can directly download it from launchpad:
fetchyahoo_2.14.0-0ubuntu1_all.deb

How to restrict a specific package from installing (apt pinning)

I tend to be very picky so there are a couple of packages which I do not want installed on my machines:

  • msttcorefonts: the Microsoft-like fonts. If you have those installed, Firefox will use them and you will get ugly windows-like font on most websites which I personally hate.
  • wine: Application to run windows programs on linux. For security reasons.
  • postfix: a mail server. Just because I do not want to run a mail server on my netbook.
  • …and some other

The best way to restrict those packages from being installed is through Apt Pinning.

Apt pinning

It is very easy to pin packages and restrict them from being installed.
You will need to edit /etc/apt/preferences and add something like this:

Package: msttcorefonts
Pin: version  0.0
Pin-Priority: -1

Package: ttf-liberation
Pin: version  0.0
Pin-Priority: -1

Package: ttf-mscorefonts-installer
Pin: version  0.0
Pin-Priority: -1

Package: wine
Pin: version  0.0
Pin-Priority: -1

Package: postfix
Pin: version  0.0
Pin-Priority: -1

Pin-Priority: -1 restricts the given version from being installed, and the version 0.0 does not exist and should be a lower version than any versions of the given packages. As a conclusion, they will never be installed.

Be careful what you pin, though, as you might be too restrictive and could prevent installing or upgrading other useful packages.

How to optimize all tables from all databases

The following command will optimize all of your databases’ tables within MySQL.
It is important to optimize tables to reduce data fragmentation.

mysqlcheck -Aop -uroot

If you are not using root replace it with your username.

-A : Check all tables in all databases. This is the same as using the –databases option and naming all the databases on the command line.
-o : optimize the tables.
-p : Prompts for a password to use when connecting to the MySQL server.
-u : The MySQL user name to use when connecting to the server.

Inspired by this article.