Leave a comment  →

Here is a script that gives some info about battery (when one is plugged)

I think that this page has mistakes (http://linux-sunxi.org/AXP209#Spec_Sheets) because discharging and charging current are inverted.

#!/bin/sh
# This program gets the battery info from PMU
# Voltage and current charging/discharging
#
# Nota : temperature can be more than real because of self heating
#######################################################################
# Copyright (c) 2014 by RzBo, Bellesserre, France
#
# Permission is granted to use the source code within this
# file in whole or in part for any use, personal or commercial,
# without restriction or limitation.
#
# No warranties, either explicit or implied, are made as to the
# suitability of this code for any purpose. Use at your own risk.
#######################################################################

# force ADC enable for battery voltage and current
i2cset -y -f 0 0x34 0x82 0xC3

################################
#read Power status register @00h
POWER_STATUS=$(i2cget -y -f 0 0x34 0x00)
#echo $POWER_STATUS

BAT_STATUS=$(($(($POWER_STATUS&0x02))/2))  # divide by 2 is like shifting rigth 1 times
#echo $(($POWER_STATUS&0x02))
echo "BAT_STATUS="$BAT_STATUS
# echo $BAT_STATUS

################################
#read Power OPERATING MODE register @01h
POWER_OP_MODE=$(i2cget -y -f 0 0x34 0x01)
#echo $POWER_OP_MODE

CHARG_IND=$(($(($POWER_OP_MODE&0x40))/64))  # divide by 64 is like shifting rigth 6 times
#echo $(($POWER_OP_MODE&0x40))
echo "CHARG_IND="$CHARG_IND
# echo $CHARG_IND

BAT_EXIST=$(($(($POWER_OP_MODE&0x20))/32))  # divide by 32 is like shifting rigth 5 times
#echo $(($POWER_OP_MODE&0x20))
echo "BAT_EXIST="$BAT_EXIST
# echo $BAT_EXIST

################################
#read Charge control register @33h
CHARGE_CTL=$(i2cget -y -f 0 0x34 0x33)
echo "CHARGE_CTL="$CHARGE_CTL
# echo $CHARGE_CTL


################################
#read Charge control register @34h
CHARGE_CTL2=$(i2cget -y -f 0 0x34 0x34)
echo "CHARGE_CTL2="$CHARGE_CTL2
# echo $CHARGE_CTL2


################################
#read battery voltage	79h, 78h	0 mV -> 000h,	1.1 mV/bit	FFFh -> 4.5045 V
BAT_VOLT_LSB=$(i2cget -y -f 0 0x34 0x79)
BAT_VOLT_MSB=$(i2cget -y -f 0 0x34 0x78)

#echo $BAT_VOLT_MSB $BAT_VOLT_LSB

BAT_BIN=$(( $(($BAT_VOLT_MSB << 4)) | $(($(($BAT_VOLT_LSB & 0xF0)) >> 4)) ))

BAT_VOLT=$(echo "($BAT_BIN*1.1)"|bc)
echo "Battery voltage = "$BAT_VOLT"mV"

###################
#read Battery Discharge Current	7Ah, 7Bh	0 mV -> 000h,	0.5 mA/bit	FFFh -> 4.095 V
BAT_IDISCHG_LSB=$(i2cget -y -f 0 0x34 0x7B)
BAT_IDISCHG_MSB=$(i2cget -y -f 0 0x34 0x7A)

#echo $BAT_IDISCHG_MSB $BAT_IDISCHG_LSB

BAT_IDISCHG_BIN=$(( $(($BAT_IDISCHG_MSB << 4)) | $(($(($BAT_IDISCHG_LSB & 0xF0)) >> 4)) ))

BAT_IDISCHG=$(echo "($BAT_IDISCHG_BIN*0.5)"|bc)
echo "Battery discharge current = "$BAT_IDISCHG"mA"

###################
#read Battery Charge Current	7Ch, 7Dh	0 mV -> 000h,	0.5 mA/bit	FFFh -> 4.095 V
BAT_ICHG_LSB=$(i2cget -y -f 0 0x34 0x7D)
BAT_ICHG_MSB=$(i2cget -y -f 0 0x34 0x7C)

#echo $BAT_ICHG_MSB $BAT_ICHG_LSB

BAT_ICHG_BIN=$(( $(($BAT_ICHG_MSB << 4)) | $(($(($BAT_ICHG_LSB & 0xF0)) >> 4)) ))

BAT_ICHG=$(echo "($BAT_ICHG_BIN*0.5)"|bc)
echo "Battery charge current = "$BAT_ICHG"mA"

this script gives the AC power status :

#!/bin/sh
# This program gets the power status (AC IN or BAT) for pcDuino3
# I2C interface with AXP209
#
#######################################################################
# Copyright (c) 2014 by RzBo, Bellesserre, France
#
# Permission is granted to use the source code within this
# file in whole or in part for any use, personal or commercial,
# without restriction or limitation.
#
# No warranties, either explicit or implied, are made as to the
# suitability of this code for any purpose. Use at your own risk.
#######################################################################

#read Power status register @00h
POWER_STATUS=$(i2cget -y -f 0 0x34 0x00)
#echo $POWER_STATUS

# bit 7 : Indicates ACIN presence 0: ACIN does not exist; 1: ACIN present
#echo "bit 7 : Indicates ACIN presence 0: ACIN does not exist; 1: ACIN present"
#echo "bit 2 : Indicates that the battery current direction 0: battery discharge; 1: The battery is charged"

AC_STATUS=$(($(($POWER_STATUS&0x80))/128))  # divide by 128 is like shifting rigth 8 times
#echo $(($POWER_STATUS&0x80))
echo "AC_STATUS="$AC_STATUS
# echo $AC_STATUS

Example :

battery charging

rzbo@ubuntu:~$ ./battery_info.sh
BAT_STATUS=0
CHARG_IND=1
BAT_EXIST=1
CHARGE_CTL=0xd0
CHARGE_CTL2=0x47
Battery voltage = 3895.1mV
Battery discharge current = 304.0mA
Battery charge current = 0mA

rzbo@ubuntu:~$ ./power_status.sh
AC_STATUS=1

Battery discharging (USB power unplugged)

rzbo@ubuntu:~$ ./battery_info.sh
BAT_STATUS=0
CHARG_IND=0
BAT_EXIST=1
CHARGE_CTL=0xd0
CHARGE_CTL2=0x47
Battery voltage = 3678.4mV
Battery discharge current = 0mA
Battery charge current = 176.0mA

rzbo@ubuntu:~$ ./power_status.sh
AC_STATUS=0

IMG_20140916_183651 IMG_20140916_183625


Leave a comment  →

Raspberry Pi is a low-cost micro-computer that is able to run Linux and has endless extension possibilities then can be also used for network video recorder (NVR) is a software program that records video in a digital format to a disk driveUSB flash drive, SD memory card or other mass storage device.

This post will guide you through the process of setting up your Raspberry Pi as a Network video recorder (NVR)

Requirements

You are going to need the following:

  • A Raspberry Pi
  • An Internet connection
  • An SD Card flashed with Raspbian OS (> 8 Gb)
  • IP or Analog camera with mjpeg streaming support or USB Camera (If you want record from Raspberry’s camera module, Please visit “Raspberry Pi as low-cost HD surveillance camera“)

Continue Reading …


Leave a comment  →

When working with anything digital, you’re going to end up reading or writing a timing diagram before long. For us, that’s meant keeping (text) notes, drawing something on a napkin, or using a tool like Inkscape. None of these are ideal.

An afternoon’s search for a better tool ended up with Wavedrom.

Just so you know where we’re coming from, here’s our list of desiderata for a timing diagram drawing solution:

  • Diagrams have a text-based representation, so their generation can be easily scripted and the results versioned and tracked throughout project development
  • Command-line rendering of images, because we like to automate everything
  • Looks good
  • Simple to use for common cases, but flexible enough to do some strange stuff when needed
  • Output modifiable when absolutely necessary: SVG would be nice

Basically, what we want is graphviz for timing diagrams.

Wavedrom nails four out of these five at the moment, and has promise to cover all of the bases. Give the online editor demo a try. We found it intuitive enough that we could make simple diagrams without even reading the fine manual. The tutorial has got you covered for more esoteric use cases.

foo

Clearly, some good thought has been put into the waveform description language, WaveJSON; it’s mostly readable and makes the essentials quick and easy. Because you can also enter straight SVG, it leaves the door open for full-fledged lunacy.

Wavedrom is written in JavaScript, and built for embedding in webpages; that’s the way they intend us to use it. On the other hand, if you want to run your own local version of the online editor, you can download it and install it locally if you’d like.

Our only quibble is that the standalone, command-line application wouldn’t generate images without the GUI on our Arch system. (Looks like there are some Google Chrome dependencies?) Otherwise, we think we’ve found our solution.

There are other applications out there. Drawtiming looks good, but we can’t quite get our head around the file format and the graphic output isn’t as flexible as we’d like: it only outputs GIF and we’re more into SVG because it can be edited easily after the fact.

There are font-based solutions that let you “type” the timing diagrams. We found Xwave and “Timing Diagram Font“. These work but aren’t particularly flexible; if you want something to happen at odd times, you’re out of luck. Plus, it just feels like a dirty hack, as if that were a bad thing.

Latex users can use tikz-timing, which makes sketching out your timing diagrams as much fun as laying out a very complex table in Latex (that is: not fun at all). On the other hand, it looks good, is ultimately flexible, outputs PDF, and would be scriptable if someone put the time in to write a nice frontend.

So for the next little while, we’re trying out Wavedrom.

What do you use for making timing diagrams?

VIA: HACKADAY


Leave a comment  →
' . get_the_title() . '

marcelclaro’s project for The Hackaday Prize aims to do just that. Instead of measuring blood directly, his project will measure blood glucose by shining light through a finger or an earlobe. Using light to detect blood glucose is something that has been studied in the lab, but so far, there aren’t any products on the market that use this technique.

There are two major problems marcel needs to overcome to turn this project into reality. The first is simply raw data for calibration. For [marcel], this is easy; he has Type 1 diabetes, and takes four glucose measurements a day. Patient heal thyself, or something.

The second problem is getting a photosensor that’s sensitive enough. By using an InGaAs PIN diode, a current-controlled oscillator, and a digital counter, [marcel] should have a sensor that’s good enough, with electronics that are cheap enough, to create some tech that is truly game changing for a few hundred million people around the world.


6 Comments  →
   by Dost Muhammad Shah    6 Comments  →
 This is an old post which I am reposting… also check Simulating Arduino Mega2560 in Proteus.

Arduino platform is a great tool for everyone who wants to play with microcontrollers in a simple and inexpensive way. It offers perhaps the quickest and easiest ways to do cool stuffs with its rich built-in library and easy to grasp interface. It’s also open-source and for this reason there are many open-source projects with it in the Internet. I have personally enjoyed it a lot. Although Arduino is pretty popular amongst many users, there is no good simulator software for it. Proteus VSM, on the other hand, is a very good circuit simulator software. However it lacks a model or simulator primitive for Arduino. Thus simulating Arduino in Proteus is in a way impossible. If these powerful tools can be synced together then a lot of new possibilities will arise. This is what I wondered from day one of Arduinoing. In this doc we will discuss how to integrate these software and simulate Arduino in Proteus.In Proteus we need to add a .hex or .coff file in a micro in order to simulate its behaviour. However Arduino works with .ino or .pde files and the folders that hold Arduino sketches don’t contain .hex or .coff files. Thus there’s no straight way. Now if there’s no straight path then we have to go around.Firstly we have to make a suitable Proteus schematic like the one shown. You can also download a template provided at the end of post.

405495_1826120830872_733664937_nOnce the schematic is completed, we have to set the fuses and clock frequency as shown

429053_1826118790821_849601661_n

Continue reading


Leave a comment  →

Asynchronous image loading

Consider a case where we are having 50 images and 50 titles and we try to load all the images/text into the listview, it won’t display anything until all the images get downloaded.

Here Asynchronous image loading process comes in picture. Asynchronous image loading is nothing but a loading process which happens in background so that it doesn’t block main UI thread and let user to play with other loaded data on the screen. Images will be getting displayed as and when it gets downloaded from background threads.

Asynchronous image loading libraries

  1. Nostra’s Universal Image loader – https://github.com/nostra13/Android-Universal-Image-Loader
  2. Picasso – http://square.github.io/picasso/
  3. UrlImageViewHelper by Koush
  4. Volley – By Android team members @ Google
  5. Novoda’s Image loader – https://github.com/novoda/ImageLoader

Let’s have a look at examples using Picasso and Universal Image loader libraries.

Example 1: Nostra’s Universal Image loader

Image loading using UniversalImageLoader

Step 1: Initialize ImageLoader configuration

public class MyApplication extends Application{
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
// Create global configuration and initialize ImageLoader with this configuration
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()).build();
ImageLoader.getInstance().init(config);
}
}

Step 2: Declare application class inside Application tag in AndroidManifest.xml file

<application android:name="MyApplication">

Step 3: Load image and display into ImageView

ImageLoader.getInstance().displayImage(objVideo.getThumb(), holder.imgVideo);

Now, Universal Image loader also provides a functionality to implement success/failure callback to check whether image loading is failed or successful.

ImageLoader.getInstance().displayImage(photoUrl, imgView,
new ImageLoadingListener() {
@Override
public void onLoadingStarted(String arg0, View arg1) {
// TODO Auto-generated method stub
findViewById(R.id.EL3002).setVisibility(View.VISIBLE);
}
@Override
public void onLoadingFailed(String arg0, View arg1,
FailReason arg2) {
// TODO Auto-generated method stub
findViewById(R.id.EL3002).setVisibility(View.GONE);
}
@Override
public void onLoadingComplete(String arg0, View arg1,
Bitmap arg2) {
// TODO Auto-generated method stub
findViewById(R.id.EL3002).setVisibility(View.GONE);
}
@Override
public void onLoadingCancelled(String arg0, View arg1) {
// TODO Auto-generated method stub
findViewById(R.id.EL3002).setVisibility(View.GONE);
}
});

Example 2: Picasso

Image loading straight way:

Picasso.with(context).load("http://postimg.org/image/wjidfl5pd/").into(imageView);

Image re-sizing:

Picasso.with(context)
.load(imageUrl)
.resize(100, 100)
.centerCrop()
.into(imageView)

Example 3: UrlImageViewHelper library

UrlImageViewHelper by Koush

It’s an android library that sets an ImageView’s contents from a url, manages image downloading, caching, and makes your coffee too.

UrlImageViewHelper will automatically download and manage all the web images and ImageViews. Duplicate urls will not be loaded into memory twice. Bitmap memory is managed by using a weak reference hash table, so as soon as the image is no longer used by you, it will be garbage collected automatically.

Image loading straight way:

UrlImageViewHelper.setUrlDrawable(imgView, "http://yourwebsite.com/image.png");

Placeholder image when image is being downloaded:

UrlImageViewHelper.setUrlDrawable(imgView, "http://yourwebsite.com/image.png", R.drawable.loadingPlaceHolder);

Cache images for a minute only:

UrlImageViewHelper.setUrlDrawable(imgView, "http://yourwebsite.com/image.png", null, 60000);

Example 4: Volley library

Yes Volley is a library developed and being managed by some android team members at Google, it was announced by Ficus Kirkpatrick during the last I/O. I wrote an article about Volley library 10 months back :) , read it and give it a try if you haven’t used it yet.

Let’s look at an example of image loading using Volley.

Step 1: Take a NetworkImageView inside your xml layout.

<com.android.volley.toolbox.NetworkImageView
android:id="@+id/imgDemo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scaleType="centerCrop"/>

Step 2: Define a ImageCache class

Yes you are reading title perfectly, we have to define an ImageCache class for initializing ImageLoader object.

public class BitmapLruCache
extends LruCache<String, Bitmap>
implements ImageLoader.ImageCache {
public BitmapLruCache() {
this(getDefaultLruCacheSize());
}
public BitmapLruCache(int sizeInKiloBytes) {
super(sizeInKiloBytes);
}
@Override
protected int sizeOf(String key, Bitmap value) {
return value.getRowBytes() * value.getHeight() / 1024;
}
@Override
public Bitmap getBitmap(String url) {
return get(url);
}
@Override
public void putBitmap(String url, Bitmap bitmap) {
put(url, bitmap);
}
public static int getDefaultLruCacheSize() {
final int maxMemory =
(int) (Runtime.getRuntime().maxMemory() / 1024);
final int cacheSize = maxMemory / 8;
return cacheSize;
}
}

Step 3: Create an ImageLoader object and load image
Create an ImageLoader object and initialize it with ImageCache object and RequestQueue object.

ImageLoader.ImageCache imageCache = new BitmapLruCache();
ImageLoader imageLoader = new ImageLoader(Volley.newRequestQueue(context), imageCache);

Step 4: Load an image into ImageView

NetworkImageView imgAvatar = (NetworkImageView) findViewById(R.id.imgDemo);
imageView.setImageUrl(url, imageLoader);

Which library to use?

Can you decide which library you would use? Let us know which and what are the reasons? :)

Selection of the library is always depends on the requirement. Let’s look at the few fact points about each library so that you would able to compare exactly and can take decision.

Picasso:

  • It’s just a one liner code to load image using Picasso.
  • No need to initialize ImageLoader and to prepare a singleton instance of image loader.
  • Picasso allows you to specify exact target image size. It’s useful when you have memory pressure or performance issues, you can trade off some image quality for speed.
  • Picasso doesn’t provide a way to prepare and store thumbnails of local images.
  • Sometimes you need to check image loading process is in which state, loading, finished execution, failed or cancelled image loading. Surprisingly It doesn’t provide a callback functionality to check any state. “fetch()” dose not pass back anything. “get()” is for synchronously read, and “load()” is for asynchronously draw a view.

Universal Image loader (UIL):

which was again probably a very first complete solution and also a most voted answer (for the image loading solution) on Stackoverflow.

  • UIL library is better in documentation and even there’s a demo example which highlights almost all the features.
  • UIL provides an easy way to download image.
  • UIL uses builders for customization. Almost everything can be configured.
  • UIL doesn’t not provide a way to specify image size directly you want to load into a view. It uses some rules based on the size of the view. Indirectly you can do it by mentioning ImageSize argument in the source code and bypass the view size checking. It’s not as flexible as Picasso.

Volley:

  • It’s officially by Android dev team, Google but still it’s not documented.
  • It’s just not an image loading library only but an asynchronous networking library
  • Developer has to define ImageCache class their self and has to initialize ImageLoader object with RequestQueue and ImageCache objects.

So now I am sure now you can be able to compare libraries. Choosing library is a bit difficult talk because it always depends on the requirement and type of projects. If the project is large then you should go for Picasso or Universal Image loader. If the project is small then you can consider to use Volley librar, because Volley isn’t an image loading library only but it tries to solve a more generic solution.).

I suggest you to start with Picasso. If you want more control and customization, go for UIL.

Read more:

  1. http://blog.bignerdranch.com/3177-solving-the-android-image-loading-problem-volley-vs-picasso/
  2. http://stackoverflow.com/questions/19995007/local-image-caching-solution-for-android-square-picasso-vs-universal-image-load
  3. https://plus.google.com/103583939320326217147/posts/bfAFC5YZ3mq

 

VIA http://www.technotalkative.com

LPC810 Breakout Board


Leave a comment  →

This basic Arm Cortex-M0+ NXP LPC810 breakout board features a FTDI programming header, USB (mini-B) connector for power only, a LM117-3.3v voltage regulator, power LED, ISP and Reset buttons and a standard 2×5-pin 0.05″ SWD debug connector. All pins are brought out to the edge of the board. Three PCBs from OSHPark.com cost me $6.55 […]

https://ucexperiment.wordpress.com/2015/02/22/lpc810-breakout-board/


2 Comments  →
   by Dost Muhammad Shah    2 Comments  →

Anyone who has a Raspberry Pi knows how exciting it is to have this little computer in the palm of your hand. Now with the introduction of the latest model, and with it being more powerful and staying at the same old price, there is so much more you can do now. Looking for something […]

http://lifehacker.com/seven-ready-made-raspberry-pi-projects-you-can-install-1691368805


Leave a comment  →

The Raspberry or Banana Pi have already pre-installed Python. If you like to stay with Groovy on these nice little devices, here are the instructions to install Groovy. GVM makes the whole process very easy and convenient. Open a terminal window and use these commands: curl -s get.gvmtool.net > installGroovy.sh chmod u+x installGroovy.sh installGroovy.sh source […]

https://jolorenz.wordpress.com/2015/03/22/how-to-install-groovy-on-a-banana-pi-or-raspberry-pi/